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

Side by Side Diff: tests/PictureTest.cpp

Issue 478673002: Expose API for whether an SkPicture contains text (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add a test Created 6 years, 4 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 | « src/core/SkPictureData.h ('k') | no next file » | 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 "SkBlurImageFilter.h" 8 #include "SkBlurImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 REPORTER_ASSERT(reporter, info4.fCTM.isIdentity()); 912 REPORTER_ASSERT(reporter, info4.fCTM.isIdentity());
913 REPORTER_ASSERT(reporter, NULL == info4.fPaint); // paint is/was uncopyable 913 REPORTER_ASSERT(reporter, NULL == info4.fPaint); // paint is/was uncopyable
914 REPORTER_ASSERT(reporter, !info4.fIsNested && !info4.fHasNestedLayer s); 914 REPORTER_ASSERT(reporter, !info4.fIsNested && !info4.fHasNestedLayer s);
915 #endif 915 #endif
916 } 916 }
917 } 917 }
918 } 918 }
919 919
920 #endif 920 #endif
921 921
922 static void test_has_text(skiatest::Reporter* reporter) {
923 SkPictureRecorder recorder;
924 SkPaint paint;
925 paint.setColor(SK_ColorBLUE);
926 SkPoint point = SkPoint::Make(10, 10);
927
928 SkCanvas* canvas = recorder.beginRecording(100, 100);
929 {
930 canvas->drawRect(SkRect::MakeWH(20, 20), paint);
931 }
932 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
933 REPORTER_ASSERT(reporter, !picture->hasText());
934
935 canvas = recorder.beginRecording(100, 100);
936 {
937 canvas->drawText("Q", 1, point.fX, point.fY, paint);
938 }
939 picture.reset(recorder.endRecording());
940 REPORTER_ASSERT(reporter, picture->hasText());
941
942 canvas = recorder.beginRecording(100, 100);
943 {
944 canvas->drawPosText("Q", 1, &point, paint);
945 }
946 picture.reset(recorder.endRecording());
947 REPORTER_ASSERT(reporter, picture->hasText());
948
949 canvas = recorder.beginRecording(100, 100);
950 {
951 canvas->drawPosTextH("Q", 1, &point.fX, point.fY, paint);
952 }
953 picture.reset(recorder.endRecording());
954 REPORTER_ASSERT(reporter, picture->hasText());
955
956 canvas = recorder.beginRecording(100, 100);
957 {
958 SkPath path;
959 path.moveTo(0, 0);
960 path.lineTo(50, 50);
961
962 canvas->drawTextOnPathHV("Q", 1, path, point.fX, point.fY, paint);
963 }
964 picture.reset(recorder.endRecording());
965 REPORTER_ASSERT(reporter, picture->hasText());
966
967 canvas = recorder.beginRecording(100, 100);
968 {
969 SkPath path;
970 path.moveTo(0, 0);
971 path.lineTo(50, 50);
972
973 canvas->drawTextOnPath("Q", 1, path, NULL, paint);
974 }
975 picture.reset(recorder.endRecording());
976 REPORTER_ASSERT(reporter, picture->hasText());
977 }
978
922 static void set_canvas_to_save_count_4(SkCanvas* canvas) { 979 static void set_canvas_to_save_count_4(SkCanvas* canvas) {
923 canvas->restoreToCount(1); 980 canvas->restoreToCount(1);
924 canvas->save(); 981 canvas->save();
925 canvas->save(); 982 canvas->save();
926 canvas->save(); 983 canvas->save();
927 } 984 }
928 985
929 /** 986 /**
930 * A canvas that records the number of saves, saveLayers and restores. 987 * A canvas that records the number of saves, saveLayers and restores.
931 */ 988 */
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 test_deleting_empty_picture(); 1611 test_deleting_empty_picture();
1555 test_serializing_empty_picture(); 1612 test_serializing_empty_picture();
1556 #else 1613 #else
1557 test_bad_bitmap(); 1614 test_bad_bitmap();
1558 #endif 1615 #endif
1559 test_unbalanced_save_restores(reporter); 1616 test_unbalanced_save_restores(reporter);
1560 test_peephole(); 1617 test_peephole();
1561 #if SK_SUPPORT_GPU 1618 #if SK_SUPPORT_GPU
1562 test_gpu_veto(reporter); 1619 test_gpu_veto(reporter);
1563 #endif 1620 #endif
1621 test_has_text(reporter);
1564 test_gatherpixelrefs(reporter); 1622 test_gatherpixelrefs(reporter);
1565 test_gatherpixelrefsandrects(reporter); 1623 test_gatherpixelrefsandrects(reporter);
1566 test_bitmap_with_encoded_data(reporter); 1624 test_bitmap_with_encoded_data(reporter);
1567 test_draw_empty(reporter); 1625 test_draw_empty(reporter);
1568 test_clip_bound_opt(reporter); 1626 test_clip_bound_opt(reporter);
1569 test_clip_expansion(reporter); 1627 test_clip_expansion(reporter);
1570 test_hierarchical(reporter); 1628 test_hierarchical(reporter);
1571 test_gen_id(reporter); 1629 test_gen_id(reporter);
1572 } 1630 }
1573 1631
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 make_bm(&replayBM, 100, 100, SK_ColorBLACK, false); 1709 make_bm(&replayBM, 100, 100, SK_ColorBLACK, false);
1652 SkCanvas replayCanvas(replayBM); 1710 SkCanvas replayCanvas(replayBM);
1653 picture->draw(&replayCanvas); 1711 picture->draw(&replayCanvas);
1654 replayCanvas.flush(); 1712 replayCanvas.flush();
1655 1713
1656 // With the bug present, at (55, 55) we would get a fully opaque red 1714 // With the bug present, at (55, 55) we would get a fully opaque red
1657 // intead of a dark red. 1715 // intead of a dark red.
1658 REPORTER_ASSERT(reporter, replayBM.getColor(30, 30) == 0xff000080); 1716 REPORTER_ASSERT(reporter, replayBM.getColor(30, 30) == 0xff000080);
1659 REPORTER_ASSERT(reporter, replayBM.getColor(55, 55) == 0xff800000); 1717 REPORTER_ASSERT(reporter, replayBM.getColor(55, 55) == 0xff800000);
1660 } 1718 }
OLDNEW
« no previous file with comments | « src/core/SkPictureData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698