| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 { | 152 { |
| 153 // Check that a color filter image filter with a crop rect cannot | 153 // Check that a color filter image filter with a crop rect cannot |
| 154 // be expressed as a color filter. | 154 // be expressed as a color filter. |
| 155 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100)); | 155 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(0, 0, 100, 100)); |
| 156 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropRect)
); | 156 SkAutoTUnref<SkImageFilter> grayWithCrop(make_grayscale(NULL, &cropRect)
); |
| 157 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL)); | 157 REPORTER_ASSERT(reporter, false == grayWithCrop->asColorFilter(NULL)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 { | 160 { |
| 161 // Check that two non-commutative matrices are concatenated in |
| 162 // the correct order. |
| 163 SkScalar blueToRedMatrix[20] = { 0 }; |
| 164 blueToRedMatrix[2] = blueToRedMatrix[18] = SK_Scalar1; |
| 165 SkScalar redToGreenMatrix[20] = { 0 }; |
| 166 redToGreenMatrix[5] = redToGreenMatrix[18] = SK_Scalar1; |
| 167 SkAutoTUnref<SkColorFilter> blueToRed(SkColorMatrixFilter::Create(blueTo
RedMatrix)); |
| 168 SkAutoTUnref<SkImageFilter> filter1(SkColorFilterImageFilter::Create(blu
eToRed.get())); |
| 169 SkAutoTUnref<SkColorFilter> redToGreen(SkColorMatrixFilter::Create(redTo
GreenMatrix)); |
| 170 SkAutoTUnref<SkImageFilter> filter2(SkColorFilterImageFilter::Create(red
ToGreen.get(), filter1.get())); |
| 171 |
| 172 SkBitmap result; |
| 173 result.allocN32Pixels(kBitmapSize, kBitmapSize); |
| 174 |
| 175 SkPaint paint; |
| 176 paint.setColor(SK_ColorBLUE); |
| 177 paint.setImageFilter(filter2.get()); |
| 178 SkCanvas canvas(result); |
| 179 canvas.clear(0x0); |
| 180 SkRect rect = SkRect::Make(SkIRect::MakeWH(kBitmapSize, kBitmapSize)); |
| 181 canvas.drawRect(rect, paint); |
| 182 uint32_t pixel = *result.getAddr32(0, 0); |
| 183 // The result here should be green, since we have effectively shifted bl
ue to green. |
| 184 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 185 } |
| 186 |
| 187 { |
| 161 // Tests pass by not asserting | 188 // Tests pass by not asserting |
| 162 SkBitmap bitmap, result; | 189 SkBitmap bitmap, result; |
| 163 make_small_bitmap(bitmap); | 190 make_small_bitmap(bitmap); |
| 164 result.allocN32Pixels(kBitmapSize, kBitmapSize); | 191 result.allocN32Pixels(kBitmapSize, kBitmapSize); |
| 165 | 192 |
| 166 { | 193 { |
| 167 // This tests for : | 194 // This tests for : |
| 168 // 1 ) location at (0,0,1) | 195 // 1 ) location at (0,0,1) |
| 169 SkPoint3 location(0, 0, SK_Scalar1); | 196 SkPoint3 location(0, 0, SK_Scalar1); |
| 170 // 2 ) location and target at same value | 197 // 2 ) location and target at same value |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 } | 761 } |
| 735 | 762 |
| 736 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { | 763 DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { |
| 737 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 764 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
| 738 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 765 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 739 SkImageInfo::MakeN32Pre
mul(1, 1), | 766 SkImageInfo::MakeN32Pre
mul(1, 1), |
| 740 0)); | 767 0)); |
| 741 test_xfermode_cropped_input(device, reporter); | 768 test_xfermode_cropped_input(device, reporter); |
| 742 } | 769 } |
| 743 #endif | 770 #endif |
| OLD | NEW |