Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: tests/PictureTest.cpp

Issue 1240753003: Revert[2] of guard to remove DrawBitmapRectFlags (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/DrawBitmapRectTest.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 canvas->drawRect(r, p); 683 canvas->drawRect(r, p);
684 684
685 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er)); 685 SkAutoTUnref<SkPicture> copy(SkPictureRecorderReplayTester::Copy(&record er));
686 686
687 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps()); 687 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps());
688 688
689 SkBitmap bm; 689 SkBitmap bm;
690 make_bm(&bm, 10, 10, SK_ColorRED, true); 690 make_bm(&bm, 10, 10, SK_ColorRED, true);
691 691
692 r.offset(5.0f, 5.0f); 692 r.offset(5.0f, 5.0f);
693 canvas->drawBitmapRectToRect(bm, NULL, r); 693 canvas->drawBitmapRect(bm, r);
694 694
695 SkAutoTUnref<SkPicture> final(recorder.endRecording()); 695 SkAutoTUnref<SkPicture> final(recorder.endRecording());
696 REPORTER_ASSERT(reporter, final->willPlayBackBitmaps()); 696 REPORTER_ASSERT(reporter, final->willPlayBackBitmaps());
697 697
698 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID()); 698 REPORTER_ASSERT(reporter, copy->uniqueID() != final->uniqueID());
699 699
700 // The snapshot shouldn't pick up any operations added after it was made 700 // The snapshot shouldn't pick up any operations added after it was made
701 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps()); 701 REPORTER_ASSERT(reporter, !copy->willPlayBackBitmaps());
702 } 702 }
703 703
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 test_cull_rect_reset(reporter); 1160 test_cull_rect_reset(reporter);
1161 } 1161 }
1162 1162
1163 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { 1163 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
1164 const SkPaint paint; 1164 const SkPaint paint;
1165 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f }; 1165 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f };
1166 const SkIRect irect = { 2, 2, 3, 3 }; 1166 const SkIRect irect = { 2, 2, 3, 3 };
1167 1167
1168 // Don't care what these record, as long as they're legal. 1168 // Don't care what these record, as long as they're legal.
1169 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint); 1169 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint);
1170 canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_Dr awBitmapRectFlag); 1170 canvas->drawBitmapRect(bitmap, &rect, rect, &paint, SkCanvas::kStrict_SrcRec tConstraint);
1171 canvas->drawBitmapNine(bitmap, irect, rect, &paint); 1171 canvas->drawBitmapNine(bitmap, irect, rect, &paint);
1172 canvas->drawSprite(bitmap, 1, 1); 1172 canvas->drawSprite(bitmap, 1, 1);
1173 } 1173 }
1174 1174
1175 static void test_draw_bitmaps(SkCanvas* canvas) { 1175 static void test_draw_bitmaps(SkCanvas* canvas) {
1176 SkBitmap empty; 1176 SkBitmap empty;
1177 draw_bitmaps(empty, canvas); 1177 draw_bitmaps(empty, canvas);
1178 empty.setInfo(SkImageInfo::MakeN32Premul(10, 10)); 1178 empty.setInfo(SkImageInfo::MakeN32Premul(10, 10));
1179 draw_bitmaps(empty, canvas); 1179 draw_bitmaps(empty, canvas);
1180 } 1180 }
1181 1181
1182 DEF_TEST(Picture_EmptyBitmap, r) { 1182 DEF_TEST(Picture_EmptyBitmap, r) {
1183 SkPictureRecorder recorder; 1183 SkPictureRecorder recorder;
1184 test_draw_bitmaps(recorder.beginRecording(10, 10)); 1184 test_draw_bitmaps(recorder.beginRecording(10, 10));
1185 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 1185 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1186 } 1186 }
1187 1187
1188 DEF_TEST(Canvas_EmptyBitmap, r) { 1188 DEF_TEST(Canvas_EmptyBitmap, r) {
1189 SkBitmap dst; 1189 SkBitmap dst;
1190 dst.allocN32Pixels(10, 10); 1190 dst.allocN32Pixels(10, 10);
1191 SkCanvas canvas(dst); 1191 SkCanvas canvas(dst);
1192 1192
1193 test_draw_bitmaps(&canvas); 1193 test_draw_bitmaps(&canvas);
1194 } 1194 }
1195 1195
1196 DEF_TEST(DontOptimizeSaveLayerDrawDrawRestore, reporter) { 1196 DEF_TEST(DontOptimizeSaveLayerDrawDrawRestore, reporter) {
1197 // This test is from crbug.com/344987. 1197 // This test is from crbug.com/344987.
1198 // The commands are: 1198 // The commands are:
1199 // saveLayer with paint that modifies alpha 1199 // saveLayer with paint that modifies alpha
1200 // drawBitmapRectToRect 1200 // drawBitmapRect
1201 // drawBitmapRectToRect 1201 // drawBitmapRect
1202 // restore 1202 // restore
1203 // The bug was that this structure was modified so that: 1203 // The bug was that this structure was modified so that:
1204 // - The saveLayer and restore were eliminated 1204 // - The saveLayer and restore were eliminated
1205 // - The alpha was only applied to the first drawBitmapRectToRect 1205 // - The alpha was only applied to the first drawBitmapRectToRect
1206 1206
1207 // This test draws blue and red squares inside a 50% transparent 1207 // This test draws blue and red squares inside a 50% transparent
1208 // layer. Both colours should show up muted. 1208 // layer. Both colours should show up muted.
1209 // When the bug is present, the red square (the second bitmap) 1209 // When the bug is present, the red square (the second bitmap)
1210 // shows upwith full opacity. 1210 // shows upwith full opacity.
1211 1211
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 1355
1356 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream()); 1356 SkAutoTDelete<SkStream> rstream(wstream.detachAsStream());
1357 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam)); 1357 SkAutoTUnref<SkPicture> deserializedPicture(SkPicture::CreateFromStream(rstr eam));
1358 1358
1359 REPORTER_ASSERT(r, SkToBool(deserializedPicture)); 1359 REPORTER_ASSERT(r, SkToBool(deserializedPicture));
1360 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1); 1360 REPORTER_ASSERT(r, deserializedPicture->cullRect().left() == 1);
1361 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2); 1361 REPORTER_ASSERT(r, deserializedPicture->cullRect().top() == 2);
1362 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3); 1362 REPORTER_ASSERT(r, deserializedPicture->cullRect().right() == 3);
1363 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4); 1363 REPORTER_ASSERT(r, deserializedPicture->cullRect().bottom() == 4);
1364 } 1364 }
OLDNEW
« no previous file with comments | « tests/DrawBitmapRectTest.cpp ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698