OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 using testing::Test; | 34 using testing::Test; |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 class ImageFilterBuilderTest : public Test { | 38 class ImageFilterBuilderTest : public Test { |
39 protected: | 39 protected: |
40 void colorSpaceTest() | 40 void colorSpaceTest() |
41 { | 41 { |
42 // Build filter tree | 42 // Build filter tree |
43 RawPtr<Filter> referenceFilter = Filter::create(1.0f); | 43 Filter* referenceFilter = Filter::create(1.0f); |
44 | 44 |
45 // Add a dummy source graphic input | 45 // Add a dummy source graphic input |
46 RawPtr<FilterEffect> sourceEffect = referenceFilter->getSourceGraphic(); | 46 FilterEffect* sourceEffect = referenceFilter->getSourceGraphic(); |
47 sourceEffect->setOperatingColorSpace(ColorSpaceDeviceRGB); | 47 sourceEffect->setOperatingColorSpace(ColorSpaceDeviceRGB); |
48 | 48 |
49 // Add a blur effect (with input : source) | 49 // Add a blur effect (with input : source) |
50 RawPtr<FilterEffect> blurEffect = | 50 FilterEffect* blurEffect = |
51 FEGaussianBlur::create(referenceFilter.get(), 3.0f, 3.0f); | 51 FEGaussianBlur::create(referenceFilter, 3.0f, 3.0f); |
52 blurEffect->setOperatingColorSpace(ColorSpaceLinearRGB); | 52 blurEffect->setOperatingColorSpace(ColorSpaceLinearRGB); |
53 blurEffect->inputEffects().append(sourceEffect); | 53 blurEffect->inputEffects().append(sourceEffect); |
54 | 54 |
55 // Add a blend effect (with inputs : blur, source) | 55 // Add a blend effect (with inputs : blur, source) |
56 RawPtr<FilterEffect> blendEffect = | 56 FilterEffect* blendEffect = |
57 FEBlend::create(referenceFilter.get(), WebBlendModeNormal); | 57 FEBlend::create(referenceFilter, WebBlendModeNormal); |
58 blendEffect->setOperatingColorSpace(ColorSpaceDeviceRGB); | 58 blendEffect->setOperatingColorSpace(ColorSpaceDeviceRGB); |
59 FilterEffectVector& blendInputs = blendEffect->inputEffects(); | 59 FilterEffectVector& blendInputs = blendEffect->inputEffects(); |
60 blendInputs.reserveCapacity(2); | 60 blendInputs.reserveCapacity(2); |
61 blendInputs.append(sourceEffect); | 61 blendInputs.append(sourceEffect); |
62 blendInputs.append(blurEffect); | 62 blendInputs.append(blurEffect); |
63 | 63 |
64 // Add a merge effect (with inputs : blur, blend) | 64 // Add a merge effect (with inputs : blur, blend) |
65 RawPtr<FilterEffect> mergeEffect = FEMerge::create(referenceFilter.get()
); | 65 FilterEffect* mergeEffect = FEMerge::create(referenceFilter); |
66 mergeEffect->setOperatingColorSpace(ColorSpaceLinearRGB); | 66 mergeEffect->setOperatingColorSpace(ColorSpaceLinearRGB); |
67 FilterEffectVector& mergeInputs = mergeEffect->inputEffects(); | 67 FilterEffectVector& mergeInputs = mergeEffect->inputEffects(); |
68 mergeInputs.reserveCapacity(2); | 68 mergeInputs.reserveCapacity(2); |
69 mergeInputs.append(blurEffect); | 69 mergeInputs.append(blurEffect); |
70 mergeInputs.append(blendEffect); | 70 mergeInputs.append(blendEffect); |
71 referenceFilter->setLastEffect(mergeEffect); | 71 referenceFilter->setLastEffect(mergeEffect); |
72 | 72 |
73 // Get SkImageFilter resulting tree | 73 // Get SkImageFilter resulting tree |
74 SkiaImageFilterBuilder builder; | 74 SkiaImageFilterBuilder builder; |
75 RefPtr<SkImageFilter> filter = builder.build(referenceFilter->lastEffect
(), ColorSpaceDeviceRGB); | 75 RefPtr<SkImageFilter> filter = builder.build(referenceFilter->lastEffect
(), ColorSpaceDeviceRGB); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 EXPECT_EQ(child->countInputs(), 1); | 112 EXPECT_EQ(child->countInputs(), 1); |
113 } | 113 } |
114 }; | 114 }; |
115 | 115 |
116 TEST_F(ImageFilterBuilderTest, testColorSpace) | 116 TEST_F(ImageFilterBuilderTest, testColorSpace) |
117 { | 117 { |
118 colorSpaceTest(); | 118 colorSpaceTest(); |
119 } | 119 } |
120 | 120 |
121 } // namespace blink | 121 } // namespace blink |
OLD | NEW |