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

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

Issue 1842033005: Image filters: fix crop rect application in SkXfermodeImageFilter. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix formatting. Created 4 years, 8 months 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
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkXfermodeImageFilter.h" 8 #include "SkXfermodeImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 SkBitmap background = src, foreground = src; 57 SkBitmap background = src, foreground = src;
58 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); 58 SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
59 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) { 59 if (!this->filterInputDeprecated(0, proxy, src, ctx, &background, &backgroun dOffset)) {
60 background.reset(); 60 background.reset();
61 } 61 }
62 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); 62 SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
63 if (!this->filterInputDeprecated(1, proxy, src, ctx, &foreground, &foregroun dOffset)) { 63 if (!this->filterInputDeprecated(1, proxy, src, ctx, &foreground, &foregroun dOffset)) {
64 foreground.reset(); 64 foreground.reset();
65 } 65 }
66 66
67 SkIRect bounds, foregroundBounds; 67 SkIRect foregroundBounds = foreground.bounds();
68 SkIRect foregroundSrcBounds = foreground.bounds(); 68 foregroundBounds.offset(foregroundOffset);
69 foregroundSrcBounds.offset(foregroundOffset); 69 SkIRect srcBounds = background.bounds();
70 if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) { 70 srcBounds.offset(backgroundOffset);
71 foregroundBounds.setEmpty(); 71 srcBounds.join(foregroundBounds);
72 foreground.reset(); 72 SkIRect bounds;
73 } 73 if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
74 SkIRect backgroundSrcBounds = background.bounds();
75 backgroundSrcBounds.offset(backgroundOffset);
76 if (!applyCropRect(ctx, backgroundSrcBounds, &bounds)) {
77 bounds.setEmpty();
78 background.reset();
79 }
80 bounds.join(foregroundBounds);
81 if (bounds.isEmpty()) {
82 return false; 74 return false;
83 } 75 }
84 76
85 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 77 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
86 if (nullptr == device.get()) { 78 if (nullptr == device.get()) {
87 return false; 79 return false;
88 } 80 }
89 SkCanvas canvas(device); 81 SkCanvas canvas(device);
90 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()) ); 82 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()) );
91 SkPaint paint; 83 SkPaint paint;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ())); 240 matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top ()));
249 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds )); 241 drawContext->drawRect(GrClip::WideOpen(), paint, matrix, SkRect::Make(bounds ));
250 242
251 offset->fX = bounds.left(); 243 offset->fX = bounds.left();
252 offset->fY = bounds.top(); 244 offset->fY = bounds.top();
253 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result); 245 GrWrapTextureInBitmap(dst, bounds.width(), bounds.height(), false, result);
254 return true; 246 return true;
255 } 247 }
256 248
257 #endif 249 #endif
OLDNEW
« no previous file with comments | « gm/xfermodeimagefilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698