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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 769953002: Remove SK_SUPPORT_LEGACY_DEEPFLATTENING. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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/opts/SkXfermode_opts_arm_neon.cpp ('k') | tests/PDFPrimitivesTest.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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBitmapSource.h" 10 #include "SkBitmapSource.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx, 52 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx,
53 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE { 53 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE {
54 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix); 54 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix);
55 return true; 55 return true;
56 } 56 }
57 57
58 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) 58 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
59 59
60 protected: 60 protected:
61 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
62 explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL ) {
63 fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr());
64 buffer.readMatrix(&fExpectedMatrix);
65 }
66 #endif
67
68 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { 61 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
69 this->INHERITED::flatten(buffer); 62 this->INHERITED::flatten(buffer);
70 buffer.writeFunctionPtr(fReporter); 63 buffer.writeFunctionPtr(fReporter);
71 buffer.writeMatrix(fExpectedMatrix); 64 buffer.writeMatrix(fExpectedMatrix);
72 } 65 }
73 66
74 private: 67 private:
75 skiatest::Reporter* fReporter; 68 skiatest::Reporter* fReporter;
76 SkMatrix fExpectedMatrix; 69 SkMatrix fExpectedMatrix;
77 70
78 typedef SkImageFilter INHERITED; 71 typedef SkImageFilter INHERITED;
79 }; 72 };
80 73
81 } 74 }
82 75
83 SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) { 76 SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) {
84 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); 77 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
85 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr() ; 78 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr() ;
86 SkMatrix matrix; 79 SkMatrix matrix;
87 buffer.readMatrix(&matrix); 80 buffer.readMatrix(&matrix);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 473 }
481 } 474 }
482 } 475 }
483 } 476 }
484 477
485 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) { 478 for (size_t i = 0; i < SK_ARRAY_COUNT(filters); ++i) {
486 SkSafeUnref(filters[i].fFilter); 479 SkSafeUnref(filters[i].fFilter);
487 } 480 }
488 } 481 }
489 482
490 static void draw_saveLayer_picture(int width, int height, int tileSize, 483 static void draw_saveLayer_picture(int width, int height, int tileSize,
491 SkBBHFactory* factory, SkBitmap* result) { 484 SkBBHFactory* factory, SkBitmap* result) {
492 485
493 SkMatrix matrix; 486 SkMatrix matrix;
494 matrix.setTranslate(SkIntToScalar(50), 0); 487 matrix.setTranslate(SkIntToScalar(50), 0);
495 488
496 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorWHITE , SkXfermode::kSrc_Mode)); 489 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateModeFilter(SK_ColorWHITE , SkXfermode::kSrc_Mode));
497 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get())) ; 490 SkAutoTUnref<SkImageFilter> cfif(SkColorFilterImageFilter::Create(cf.get())) ;
498 SkAutoTUnref<SkImageFilter> imageFilter(SkMatrixImageFilter::Create(matrix, SkPaint::kNone_FilterLevel, cfif.get())); 491 SkAutoTUnref<SkImageFilter> imageFilter(SkMatrixImageFilter::Create(matrix, SkPaint::kNone_FilterLevel, cfif.get()));
499 492
500 SkPaint paint; 493 SkPaint paint;
501 paint.setImageFilter(imageFilter.get()); 494 paint.setImageFilter(imageFilter.get());
502 SkPictureRecorder recorder; 495 SkPictureRecorder recorder;
503 SkRect bounds = SkRect::Make(SkIRect::MakeXYWH(0, 0, 50, 50)); 496 SkRect bounds = SkRect::Make(SkIRect::MakeXYWH(0, 0, 50, 50));
504 SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(width), 497 SkCanvas* recordingCanvas = recorder.beginRecording(SkIntToScalar(width),
505 SkIntToScalar(height), 498 SkIntToScalar(height),
506 factory, 0); 499 factory, 0);
507 recordingCanvas->translate(-55, 0); 500 recordingCanvas->translate(-55, 0);
508 recordingCanvas->saveLayer(&bounds, &paint); 501 recordingCanvas->saveLayer(&bounds, &paint);
509 recordingCanvas->restore(); 502 recordingCanvas->restore();
510 SkAutoTUnref<SkPicture> picture1(recorder.endRecording()); 503 SkAutoTUnref<SkPicture> picture1(recorder.endRecording());
511 504
512 result->allocN32Pixels(width, height); 505 result->allocN32Pixels(width, height);
513 SkCanvas canvas(*result); 506 SkCanvas canvas(*result);
514 canvas.clear(0); 507 canvas.clear(0);
515 canvas.clipRect(SkRect::Make(SkIRect::MakeWH(tileSize, tileSize))); 508 canvas.clipRect(SkRect::Make(SkIRect::MakeWH(tileSize, tileSize)));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 SkCanvas canvas2(result2); 611 SkCanvas canvas2(result2);
619 int tileSize = 8; 612 int tileSize = 8;
620 613
621 canvas1.clear(0); 614 canvas1.clear(0);
622 canvas2.clear(0); 615 canvas2.clear(0);
623 616
624 SkRTreeFactory factory; 617 SkRTreeFactory factory;
625 618
626 SkPictureRecorder recorder1, recorder2; 619 SkPictureRecorder recorder1, recorder2;
627 // The only difference between these two pictures is that one has RTree acel eration. 620 // The only difference between these two pictures is that one has RTree acel eration.
628 SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width), 621 SkCanvas* recordingCanvas1 = recorder1.beginRecording(SkIntToScalar(width),
629 SkIntToScalar(height), 622 SkIntToScalar(height),
630 NULL, 0); 623 NULL, 0);
631 SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width), 624 SkCanvas* recordingCanvas2 = recorder2.beginRecording(SkIntToScalar(width),
632 SkIntToScalar(height), 625 SkIntToScalar(height),
633 &factory, 0); 626 &factory, 0);
634 draw_blurred_rect(recordingCanvas1); 627 draw_blurred_rect(recordingCanvas1);
635 draw_blurred_rect(recordingCanvas2); 628 draw_blurred_rect(recordingCanvas2);
636 SkAutoTUnref<SkPicture> picture1(recorder1.endRecording()); 629 SkAutoTUnref<SkPicture> picture1(recorder1.endRecording());
637 SkAutoTUnref<SkPicture> picture2(recorder2.endRecording()); 630 SkAutoTUnref<SkPicture> picture2(recorder2.endRecording());
638 for (int y = 0; y < height; y += tileSize) { 631 for (int y = 0; y < height; y += tileSize) {
639 for (int x = 0; x < width; x += tileSize) { 632 for (int x = 0; x < width; x += tileSize) {
640 SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, til eSize)); 633 SkRect tileRect = SkRect::Make(SkIRect::MakeXYWH(x, y, tileSize, til eSize));
641 draw_picture_clipped(&canvas1, tileRect, picture1); 634 draw_picture_clipped(&canvas1, tileRect, picture1);
642 draw_picture_clipped(&canvas2, tileRect, picture2); 635 draw_picture_clipped(&canvas2, tileRect, picture2);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1088
1096 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { 1089 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) {
1097 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0)); 1090 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp e>(0));
1098 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, 1091 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context,
1099 SkImageInfo::MakeN32Pre mul(1, 1), 1092 SkImageInfo::MakeN32Pre mul(1, 1),
1100 gProps, 1093 gProps,
1101 0)); 1094 0));
1102 test_negative_blur_sigma(device, reporter); 1095 test_negative_blur_sigma(device, reporter);
1103 } 1096 }
1104 #endif 1097 #endif
OLDNEW
« no previous file with comments | « src/opts/SkXfermode_opts_arm_neon.cpp ('k') | tests/PDFPrimitivesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698