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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx, | 50 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context& ctx, |
51 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { | 51 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE { |
52 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix); | 52 REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix); |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) | 56 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter) |
57 | 57 |
58 protected: | 58 protected: |
| 59 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
59 explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL
) { | 60 explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0, NULL
) { |
60 fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr()); | 61 fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr()); |
61 buffer.readMatrix(&fExpectedMatrix); | 62 buffer.readMatrix(&fExpectedMatrix); |
62 } | 63 } |
| 64 #endif |
63 | 65 |
64 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { | 66 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE { |
| 67 this->INHERITED::flatten(buffer); |
65 buffer.writeFunctionPtr(fReporter); | 68 buffer.writeFunctionPtr(fReporter); |
66 buffer.writeMatrix(fExpectedMatrix); | 69 buffer.writeMatrix(fExpectedMatrix); |
67 } | 70 } |
68 | 71 |
69 private: | 72 private: |
70 skiatest::Reporter* fReporter; | 73 skiatest::Reporter* fReporter; |
71 SkMatrix fExpectedMatrix; | 74 SkMatrix fExpectedMatrix; |
| 75 |
| 76 typedef SkImageFilter INHERITED; |
72 }; | 77 }; |
73 | 78 |
74 } | 79 } |
75 | 80 |
| 81 SkFlattenable* MatrixTestImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 82 SK_IMAGEFILTER_UNFLATTEN_COMMON(1); |
| 83 skiatest::Reporter* reporter = (skiatest::Reporter*)buffer.readFunctionPtr()
; |
| 84 SkMatrix matrix; |
| 85 buffer.readMatrix(&matrix); |
| 86 return SkNEW_ARGS(MatrixTestImageFilter, (reporter, matrix)); |
| 87 } |
| 88 |
76 static void make_small_bitmap(SkBitmap& bitmap) { | 89 static void make_small_bitmap(SkBitmap& bitmap) { |
77 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); | 90 bitmap.allocN32Pixels(kBitmapSize, kBitmapSize); |
78 SkCanvas canvas(bitmap); | 91 SkCanvas canvas(bitmap); |
79 canvas.clear(0x00000000); | 92 canvas.clear(0x00000000); |
80 SkPaint darkPaint; | 93 SkPaint darkPaint; |
81 darkPaint.setColor(0xFF804020); | 94 darkPaint.setColor(0xFF804020); |
82 SkPaint lightPaint; | 95 SkPaint lightPaint; |
83 lightPaint.setColor(0xFF244484); | 96 lightPaint.setColor(0xFF244484); |
84 const int i = kBitmapSize / 4; | 97 const int i = kBitmapSize / 4; |
85 for (int y = 0; y < kBitmapSize; y += i) { | 98 for (int y = 0; y < kBitmapSize; y += i) { |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 } | 861 } |
849 | 862 |
850 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 863 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
851 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 864 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
852 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 865 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
853 SkImageInfo::MakeN32Pre
mul(1, 1), | 866 SkImageInfo::MakeN32Pre
mul(1, 1), |
854 0)); | 867 0)); |
855 test_xfermode_cropped_input(device, reporter); | 868 test_xfermode_cropped_input(device, reporter); |
856 } | 869 } |
857 #endif | 870 #endif |
OLD | NEW |