OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) | 48 MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expected
Matrix) |
49 : SkImageFilter(0, NULL), fReporter(reporter), fExpectedMatrix(expectedMat
rix) { | 49 : SkImageFilter(0, NULL), fReporter(reporter), fExpectedMatrix(expectedMat
rix) { |
50 } | 50 } |
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_TO_STRING_OVERRIDE() |
58 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) | 59 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) |
59 | 60 |
60 protected: | 61 protected: |
61 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 62 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { |
62 this->INHERITED::flatten(buffer); | 63 this->INHERITED::flatten(buffer); |
63 buffer.writeFunctionPtr(fReporter); | 64 buffer.writeFunctionPtr(fReporter); |
64 buffer.writeMatrix(fExpectedMatrix); | 65 buffer.writeMatrix(fExpectedMatrix); |
65 } | 66 } |
66 | 67 |
67 private: | 68 private: |
68 skiatest::Reporter* fReporter; | 69 skiatest::Reporter* fReporter; |
69 SkMatrix fExpectedMatrix; | 70 SkMatrix fExpectedMatrix; |
70 | 71 |
71 typedef SkImageFilter INHERITED; | 72 typedef SkImageFilter INHERITED; |
72 }; | 73 }; |
73 | 74 |
74 } | 75 } |
75 | 76 |
76 SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) { | 77 SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) { |
77 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 78 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
78 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr()
; | 79 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr()
; |
79 SkMatrix matrix; | 80 SkMatrix matrix; |
80 buffer.readMatrix(&matrix); | 81 buffer.readMatrix(&matrix); |
81 return SkNEW_ARGS(MatrixTestImageFilter, (reporter, matrix)); | 82 return SkNEW_ARGS(MatrixTestImageFilter, (reporter, matrix)); |
82 } | 83 } |
83 | 84 |
| 85 #ifndef SK_IGNORE_TO_STRING |
| 86 void MatrixTestImageFilter::toString(SkString* str) const { |
| 87 str->appendf("MatrixTestImageFilter: ("); |
| 88 str->append(")"); |
| 89 } |
| 90 #endif |
| 91 |
84 static void make_small_bitmap(SkBitmap& bitmap) { | 92 static void make_small_bitmap(SkBitmap& bitmap) { |
85 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); | 93 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); |
86 SkCanvas canvas(bitmap); | 94 SkCanvas canvas(bitmap); |
87 canvas.clear(0x00000000); | 95 canvas.clear(0x00000000); |
88 SkPaint darkPaint; | 96 SkPaint darkPaint; |
89 darkPaint.setColor(0xFF804020); | 97 darkPaint.setColor(0xFF804020); |
90 SkPaint lightPaint; | 98 SkPaint lightPaint; |
91 lightPaint.setColor(0xFF244484); | 99 lightPaint.setColor(0xFF244484); |
92 const int i = kBitmapSize / 4; | 100 const int i = kBitmapSize / 4; |
93 for (int y = 0; y < kBitmapSize; y += i) { | 101 for (int y = 0; y < kBitmapSize; y += i) { |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 | 1096 |
1089 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { | 1097 DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { |
1090 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1098 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
1091 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1099 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1092 SkImageInfo::MakeN32Pre
mul(1, 1), | 1100 SkImageInfo::MakeN32Pre
mul(1, 1), |
1093 gProps, | 1101 gProps, |
1094 0)); | 1102 0)); |
1095 test_negative_blur_sigma(device, reporter); | 1103 test_negative_blur_sigma(device, reporter); |
1096 } | 1104 } |
1097 #endif | 1105 #endif |
OLD | NEW |