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

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

Issue 137423005: Implement a computeFastBounds() traversal for SkImageFilter. This allows for correct culling of pri… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Win build; update to ToT Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkMorphologyImageFilter.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 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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft), 58 canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
59 SkIntToScalar(srcOffset.fY - bounds.fTop)); 59 SkIntToScalar(srcOffset.fY - bounds.fTop));
60 canvas.drawBitmap(src, fOffset.x(), fOffset.y(), &paint); 60 canvas.drawBitmap(src, fOffset.x(), fOffset.y(), &paint);
61 *result = device->accessBitmap(false); 61 *result = device->accessBitmap(false);
62 offset->fX = bounds.fLeft; 62 offset->fX = bounds.fLeft;
63 offset->fY = bounds.fTop; 63 offset->fY = bounds.fTop;
64 } 64 }
65 return true; 65 return true;
66 } 66 }
67 67
68 void SkOffsetImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) cons t {
69 if (getInput(0)) {
70 getInput(0)->computeFastBounds(src, dst);
71 } else {
72 *dst = src;
73 }
74 dst->offset(fOffset.fX, fOffset.fY);
75 }
76
68 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm , 77 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm ,
69 SkIRect* dst) { 78 SkIRect* dst) {
70 SkVector vec; 79 SkVector vec;
71 ctm.mapVectors(&vec, &fOffset, 1); 80 ctm.mapVectors(&vec, &fOffset, 1);
72 81
73 *dst = src; 82 *dst = src;
74 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); 83 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY));
75 return true; 84 return true;
76 } 85 }
77 86
78 void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 87 void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
79 this->INHERITED::flatten(buffer); 88 this->INHERITED::flatten(buffer);
80 buffer.writePoint(fOffset); 89 buffer.writePoint(fOffset);
81 } 90 }
82 91
83 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input, 92 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input,
84 const CropRect* cropRect) : INHERITED(i nput, cropRect) { 93 const CropRect* cropRect) : INHERITED(i nput, cropRect) {
85 fOffset.set(dx, dy); 94 fOffset.set(dx, dy);
86 } 95 }
87 96
88 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) 97 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer)
89 : INHERITED(1, buffer) { 98 : INHERITED(1, buffer) {
90 buffer.readPoint(&fOffset); 99 buffer.readPoint(&fOffset);
91 buffer.validate(SkScalarIsFinite(fOffset.fX) && 100 buffer.validate(SkScalarIsFinite(fOffset.fX) &&
92 SkScalarIsFinite(fOffset.fY)); 101 SkScalarIsFinite(fOffset.fY));
93 } 102 }
OLDNEW
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698