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

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

Issue 112683004: Bounds fixes for SkXfermodeImageFilter: (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add comment to ignored-tests Created 7 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 | Annotate | Revision Log
« no previous file with comments | « expectations/gm/ignored-tests.txt ('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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 if (backgroundInput && 54 if (backgroundInput &&
55 !backgroundInput->filterImage(proxy, src, ctm, &background, &backgroundO ffset)) { 55 !backgroundInput->filterImage(proxy, src, ctm, &background, &backgroundO ffset)) {
56 return false; 56 return false;
57 } 57 }
58 SkIPoint foregroundOffset = SkIPoint::Make(0, 0); 58 SkIPoint foregroundOffset = SkIPoint::Make(0, 0);
59 if (foregroundInput && 59 if (foregroundInput &&
60 !foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundO ffset)) { 60 !foregroundInput->filterImage(proxy, src, ctm, &foreground, &foregroundO ffset)) {
61 return false; 61 return false;
62 } 62 }
63 63
64 SkIRect bounds; 64 SkIRect bounds, foregroundBounds;
65 background.getBounds(&bounds); 65 background.getBounds(&bounds);
66 bounds.offset(backgroundOffset);
67 foreground.getBounds(&foregroundBounds);
68 foregroundBounds.offset(foregroundOffset);
69 bounds.join(foregroundBounds);
66 if (!applyCropRect(&bounds, ctm)) { 70 if (!applyCropRect(&bounds, ctm)) {
67 return false; 71 return false;
68 } 72 }
69 backgroundOffset.fX -= bounds.left();
70 backgroundOffset.fY -= bounds.top();
71 foregroundOffset.fX -= bounds.left();
72 foregroundOffset.fY -= bounds.top();
73 73
74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height())); 74 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds .height()));
75 if (NULL == device.get()) { 75 if (NULL == device.get()) {
76 return false; 76 return false;
77 } 77 }
78 SkCanvas canvas(device); 78 SkCanvas canvas(device);
79 canvas.translate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()) );
79 SkPaint paint; 80 SkPaint paint;
80 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 81 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
81 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX), 82 canvas.drawBitmap(background, SkIntToScalar(backgroundOffset.fX),
82 SkIntToScalar(backgroundOffset.fY), &paint); 83 SkIntToScalar(backgroundOffset.fY), &paint);
83 paint.setXfermode(fMode); 84 paint.setXfermode(fMode);
84 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX), 85 canvas.drawBitmap(foreground, SkIntToScalar(foregroundOffset.fX),
85 SkIntToScalar(foregroundOffset.fY), &paint); 86 SkIntToScalar(foregroundOffset.fY), &paint);
87 canvas.clipRect(SkRect::Make(foregroundBounds), SkRegion::kDifference_Op);
88 paint.setColor(SK_ColorTRANSPARENT);
89 canvas.drawPaint(paint);
86 *dst = device->accessBitmap(false); 90 *dst = device->accessBitmap(false);
87 offset->fX += bounds.left(); 91 offset->fX += bounds.left();
88 offset->fY += bounds.top(); 92 offset->fY += bounds.top();
89 return true; 93 return true;
90 } 94 }
91 95
92 #if SK_SUPPORT_GPU 96 #if SK_SUPPORT_GPU
93 97
94 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, 98 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
95 const SkBitmap& src, 99 const SkBitmap& src,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen d(dm)); 156 foregroundPaint.setBlendFunc(sk_blend_to_grblend(sm), sk_blend_to_grblen d(dm));
153 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix); 157 foregroundPaint.addColorTextureEffect(foregroundTex, foregroundMatrix);
154 context->drawRect(foregroundPaint, srcRect); 158 context->drawRect(foregroundPaint, srcRect);
155 } 159 }
156 offset->fX += backgroundOffset.fX; 160 offset->fX += backgroundOffset.fX;
157 offset->fY += backgroundOffset.fY; 161 offset->fY += backgroundOffset.fY;
158 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul t); 162 return SkImageFilterUtils::WrapTexture(dst, src.width(), src.height(), resul t);
159 } 163 }
160 164
161 #endif 165 #endif
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698