OLD | NEW |
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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 SkPaint paint; | 836 SkPaint paint; |
837 SkScalar intervals [] = { 10, 20 }; | 837 SkScalar intervals [] = { 10, 20 }; |
838 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); | 838 SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); |
839 paint.setPathEffect(pe)->unref(); | 839 paint.setPathEffect(pe)->unref(); |
840 | 840 |
841 canvas->drawRect(SkRect::MakeWH(10, 10), paint); | 841 canvas->drawRect(SkRect::MakeWH(10, 10), paint); |
842 } | 842 } |
843 picture.reset(recorder.endRecording()); | 843 picture.reset(recorder.endRecording()); |
844 // ... but only when applied to drawPoint() calls | 844 // ... but only when applied to drawPoint() calls |
845 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); | 845 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
| 846 |
| 847 // Nest the previous picture inside a new one. |
| 848 // This doesn't work in the old backend. |
| 849 if (useNewPath) { |
| 850 canvas = GENERATE_CANVAS(recorder, useNewPath); |
| 851 { |
| 852 canvas->drawPicture(picture.get()); |
| 853 } |
| 854 picture.reset(recorder.endRecording()); |
| 855 REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL)); |
| 856 } |
846 } | 857 } |
847 | 858 |
848 #undef GENERATE_CANVAS | 859 #undef GENERATE_CANVAS |
849 | 860 |
850 static void test_gpu_picture_optimization(skiatest::Reporter* reporter, | 861 static void test_gpu_picture_optimization(skiatest::Reporter* reporter, |
851 GrContextFactory* factory) { | 862 GrContextFactory* factory) { |
852 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { | 863 for (int i= 0; i < GrContextFactory::kGLContextTypeCnt; ++i) { |
853 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; | 864 GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContext
Type) i; |
854 | 865 |
855 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { | 866 if (!GrContextFactory::IsRenderingGLContext(glCtxType)) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 canvas = BEGIN_RECORDING; | 1047 canvas = BEGIN_RECORDING; |
1037 { | 1048 { |
1038 SkPath path; | 1049 SkPath path; |
1039 path.moveTo(0, 0); | 1050 path.moveTo(0, 0); |
1040 path.lineTo(50, 50); | 1051 path.lineTo(50, 50); |
1041 | 1052 |
1042 canvas->drawTextOnPath("Q", 1, path, NULL, SkPaint()); | 1053 canvas->drawTextOnPath("Q", 1, path, NULL, SkPaint()); |
1043 } | 1054 } |
1044 picture.reset(recorder.endRecording()); | 1055 picture.reset(recorder.endRecording()); |
1045 REPORTER_ASSERT(reporter, picture->hasText()); | 1056 REPORTER_ASSERT(reporter, picture->hasText()); |
| 1057 |
| 1058 // Nest the previous picture inside a new one. |
| 1059 // This doesn't work in the old backend. |
| 1060 if (useNewPath) { |
| 1061 canvas = BEGIN_RECORDING; |
| 1062 { |
| 1063 canvas->drawPicture(picture.get()); |
| 1064 } |
| 1065 picture.reset(recorder.endRecording()); |
| 1066 REPORTER_ASSERT(reporter, picture->hasText()); |
| 1067 } |
1046 #undef BEGIN_RECORDING | 1068 #undef BEGIN_RECORDING |
1047 } | 1069 } |
1048 | 1070 |
1049 static void set_canvas_to_save_count_4(SkCanvas* canvas) { | 1071 static void set_canvas_to_save_count_4(SkCanvas* canvas) { |
1050 canvas->restoreToCount(1); | 1072 canvas->restoreToCount(1); |
1051 canvas->save(); | 1073 canvas->save(); |
1052 canvas->save(); | 1074 canvas->save(); |
1053 canvas->save(); | 1075 canvas->save(); |
1054 } | 1076 } |
1055 | 1077 |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); | 1851 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); |
1830 | 1852 |
1831 SkCanvas big(640, 480), small(300, 200); | 1853 SkCanvas big(640, 480), small(300, 200); |
1832 | 1854 |
1833 picture->draw(&big); | 1855 picture->draw(&big); |
1834 REPORTER_ASSERT(r, bbh.searchCalls == 0); | 1856 REPORTER_ASSERT(r, bbh.searchCalls == 0); |
1835 | 1857 |
1836 picture->draw(&small); | 1858 picture->draw(&small); |
1837 REPORTER_ASSERT(r, bbh.searchCalls == 1); | 1859 REPORTER_ASSERT(r, bbh.searchCalls == 1); |
1838 } | 1860 } |
OLD | NEW |