Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Side by Side Diff: src/effects/SkMatrixConvolutionImageFilter.cpp

Issue 1308703007: Fix filter primitive bounds computations. (Closed) Base URL: https://skia.googlesource.com/skia.git@saveLayer-bounds-not-transformed
Patch Set: Fix comment style; remove useless param names Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkMatrixConvolutionImageFilter.h" 8 #include "SkMatrixConvolutionImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 SkIPoint srcOffset = SkIPoint::Make(0, 0); 273 SkIPoint srcOffset = SkIPoint::Make(0, 0);
274 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { 274 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) {
275 return false; 275 return false;
276 } 276 }
277 277
278 if (src.colorType() != kN32_SkColorType) { 278 if (src.colorType() != kN32_SkColorType) {
279 return false; 279 return false;
280 } 280 }
281 281
282 SkIRect bounds; 282 SkIRect bounds;
283 if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &bounds, &src)) { 283 if (!this->applyCropRect(this->mapContext(ctx), proxy, src, &srcOffset, &bou nds, &src)) {
284 return false; 284 return false;
285 } 285 }
286 286
287 if (!fConvolveAlpha && !src.isOpaque()) { 287 if (!fConvolveAlpha && !src.isOpaque()) {
288 src = unpremultiplyBitmap(proxy, src); 288 src = unpremultiplyBitmap(proxy, src);
289 } 289 }
290 290
291 SkAutoLockPixels alp(src); 291 SkAutoLockPixels alp(src);
292 if (!src.getPixels()) { 292 if (!src.getPixels()) {
293 return false; 293 return false;
(...skipping 21 matching lines...) Expand all
315 SkIRect right = SkIRect::MakeLTRB(interior.right(), interior.top(), 315 SkIRect right = SkIRect::MakeLTRB(interior.right(), interior.top(),
316 bounds.right(), interior.bottom()); 316 bounds.right(), interior.bottom());
317 filterBorderPixels(src, result, top, bounds); 317 filterBorderPixels(src, result, top, bounds);
318 filterBorderPixels(src, result, left, bounds); 318 filterBorderPixels(src, result, left, bounds);
319 filterInteriorPixels(src, result, interior, bounds); 319 filterInteriorPixels(src, result, interior, bounds);
320 filterBorderPixels(src, result, right, bounds); 320 filterBorderPixels(src, result, right, bounds);
321 filterBorderPixels(src, result, bottom, bounds); 321 filterBorderPixels(src, result, bottom, bounds);
322 return true; 322 return true;
323 } 323 }
324 324
325 bool SkMatrixConvolutionImageFilter::onFilterBounds(const SkIRect& src, const Sk Matrix& ctm, 325 void SkMatrixConvolutionImageFilter::onFilterNodeBounds(const SkIRect& src, cons t SkMatrix& ctm,
326 SkIRect* dst) const { 326 SkIRect* dst, MapDirection d irection) const {
327 SkIRect bounds = src; 327 *dst = src;
328 bounds.fRight += fKernelSize.width() - 1; 328 int w = fKernelSize.width() - 1, h = fKernelSize.height() - 1;
329 bounds.fBottom += fKernelSize.height() - 1; 329 dst->fRight += w;
330 bounds.offset(-fKernelOffset); 330 dst->fBottom += h;
331 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { 331 if (kReverse_MapDirection == direction) {
332 return false; 332 dst->offset(-fKernelOffset);
333 } else {
334 dst->offset(fKernelOffset - SkIPoint::Make(w, h));
333 } 335 }
334 *dst = bounds;
335 return true;
336 } 336 }
337 337
338 bool SkMatrixConvolutionImageFilter::canComputeFastBounds() const { 338 bool SkMatrixConvolutionImageFilter::canComputeFastBounds() const {
339 // Because the kernel is applied in device-space, we have no idea what 339 // Because the kernel is applied in device-space, we have no idea what
340 // pixels it will affect in object-space. 340 // pixels it will affect in object-space.
341 return false; 341 return false;
342 } 342 }
343 343
344 #if SK_SUPPORT_GPU 344 #if SK_SUPPORT_GPU
345 345
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]); 388 str->appendf("%f ", fKernel[y * fKernelSize.width() + x]);
389 } 389 }
390 } 390 }
391 str->appendf(")"); 391 str->appendf(")");
392 str->appendf("gain: %f bias: %f ", fGain, fBias); 392 str->appendf("gain: %f bias: %f ", fGain, fBias);
393 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY); 393 str->appendf("offset: (%d, %d) ", fKernelOffset.fX, fKernelOffset.fY);
394 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false"); 394 str->appendf("convolveAlpha: %s", fConvolveAlpha ? "true" : "false");
395 str->append(")"); 395 str->append(")");
396 } 396 }
397 #endif 397 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698