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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, N
ULL, &cropRect)); | 1132 SkAutoTUnref<SkImageFilter> offsetFilter(SkOffsetImageFilter::Create(0, 0, N
ULL, &cropRect)); |
1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); | 1133 SkAutoTUnref<SkImageFilter> blurFilter(makeBlur()); |
1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); | 1134 SkAutoTUnref<SkImageFilter> composedFilter(SkComposeImageFilter::Create(blur
Filter, offsetFilter.get())); |
1135 SkBitmap result; | 1135 SkBitmap result; |
1136 SkIPoint offset; | 1136 SkIPoint offset; |
1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); | 1137 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); |
1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); | 1138 REPORTER_ASSERT(reporter, composedFilter->filterImage(&proxy, bitmap, ctx, &
result, &offset)); |
1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); | 1139 REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0); |
1140 } | 1140 } |
1141 | 1141 |
| 1142 DEF_TEST(PartialCropRect, reporter) { |
| 1143 SkBitmap bitmap; |
| 1144 bitmap.allocN32Pixels(100, 100); |
| 1145 bitmap.eraseARGB(0, 0, 0, 0); |
| 1146 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1147 SkBitmapDevice device(bitmap, props); |
| 1148 SkImageFilter::Proxy proxy(&device); |
| 1149 |
| 1150 SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(100, 0, 20, 30), |
| 1151 SkImageFilter::CropRect::kHasRight_CropEdge | SkImageFilter::CropRect::k
HasBottom_CropEdge); |
| 1152 SkAutoTUnref<SkImageFilter> filter(make_grayscale(NULL, &cropRect)); |
| 1153 SkBitmap result; |
| 1154 SkIPoint offset; |
| 1155 SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); |
| 1156 REPORTER_ASSERT(reporter, filter->filterImage(&proxy, bitmap, ctx, &result,
&offset)); |
| 1157 REPORTER_ASSERT(reporter, offset.fX == 0); |
| 1158 REPORTER_ASSERT(reporter, offset.fY == 0); |
| 1159 REPORTER_ASSERT(reporter, result.width() == 20); |
| 1160 REPORTER_ASSERT(reporter, result.height() == 30); |
| 1161 } |
| 1162 |
1142 #if SK_SUPPORT_GPU | 1163 #if SK_SUPPORT_GPU |
1143 | 1164 |
1144 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { | 1165 DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { |
1145 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); | 1166 GrContext* context = factory->get(static_cast<GrContextFactory::GLContextTyp
e>(0)); |
1146 if (NULL == context) { | 1167 if (NULL == context) { |
1147 return; | 1168 return; |
1148 } | 1169 } |
1149 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1170 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1150 | 1171 |
1151 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1172 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 SkSurface::kNo_Budgeted
, | 1227 SkSurface::kNo_Budgeted
, |
1207 SkImageInfo::MakeN32Pre
mul(1, 1), | 1228 SkImageInfo::MakeN32Pre
mul(1, 1), |
1208 0, | 1229 0, |
1209 &props, | 1230 &props, |
1210 SkGpuDevice::kUninit_In
itContents)); | 1231 SkGpuDevice::kUninit_In
itContents)); |
1211 SkImageFilter::Proxy proxy(device); | 1232 SkImageFilter::Proxy proxy(device); |
1212 | 1233 |
1213 test_negative_blur_sigma(&proxy, reporter); | 1234 test_negative_blur_sigma(&proxy, reporter); |
1214 } | 1235 } |
1215 #endif | 1236 #endif |
OLD | NEW |