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

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 1800263002: Fix pointer aliasing bug in SkImageFilter::computeFastBounds. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: code review comments on unit test Created 4 years, 9 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 | « no previous file | tests/ImageFilterTest.cpp » ('j') | 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 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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 #include "SkImageFilterCacheKey.h" 9 #include "SkImageFilterCacheKey.h"
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 this->getCropRect().applyTo(temp, ctm, dst); 306 this->getCropRect().applyTo(temp, ctm, dst);
307 return true; 307 return true;
308 } 308 }
309 } 309 }
310 310
311 void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { 311 void SkImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const {
312 if (0 == fInputCount) { 312 if (0 == fInputCount) {
313 *dst = src; 313 *dst = src;
314 return; 314 return;
315 } 315 }
316 // We can't work directly on dst, since src and dst may alias.
317 SkRect combinedBounds;
316 if (this->getInput(0)) { 318 if (this->getInput(0)) {
317 this->getInput(0)->computeFastBounds(src, dst); 319 this->getInput(0)->computeFastBounds(src, &combinedBounds);
318 } else { 320 } else {
319 *dst = src; 321 combinedBounds = src;
320 } 322 }
321 for (int i = 1; i < fInputCount; i++) { 323 for (int i = 1; i < fInputCount; i++) {
322 SkImageFilter* input = this->getInput(i); 324 SkImageFilter* input = this->getInput(i);
323 if (input) { 325 if (input) {
324 SkRect bounds; 326 SkRect bounds;
325 input->computeFastBounds(src, &bounds); 327 input->computeFastBounds(src, &bounds);
326 dst->join(bounds); 328 combinedBounds.join(bounds);
327 } else { 329 } else {
328 dst->join(src); 330 combinedBounds.join(src);
329 } 331 }
330 } 332 }
333 *dst = combinedBounds;
331 } 334 }
332 335
333 bool SkImageFilter::canComputeFastBounds() const { 336 bool SkImageFilter::canComputeFastBounds() const {
334 for (int i = 0; i < fInputCount; i++) { 337 for (int i = 0; i < fInputCount; i++) {
335 SkImageFilter* input = this->getInput(i); 338 SkImageFilter* input = this->getInput(i);
336 if (input && !input->canComputeFastBounds()) { 339 if (input && !input->canComputeFastBounds()) {
337 return false; 340 return false;
338 } 341 }
339 } 342 }
340 return true; 343 return true;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 } 811 }
809 return dev; 812 return dev;
810 } 813 }
811 814
812 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src, 815 bool SkImageFilter::DeviceProxy::filterImage(const SkImageFilter* filter, const SkBitmap& src,
813 const SkImageFilter::Context& ctx, 816 const SkImageFilter::Context& ctx,
814 SkBitmap* result, SkIPoint* offset) { 817 SkBitmap* result, SkIPoint* offset) {
815 return fDevice->filterImage(filter, src, ctx, result, offset); 818 return fDevice->filterImage(filter, src, ctx, result, offset);
816 } 819 }
817 820
OLDNEW
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698