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

Unified Diff: src/core/SkImageFilter.cpp

Issue 19775006: Implement crop rect for SkImageFilter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix comments Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/effects/SkColorFilterImageFilter.h ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index ddd6449490ba0c0734cfaa925a610f24f704485b..ff060a1a52cb8e764905959f62d06af9617e53ee 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -18,22 +18,27 @@
SK_DEFINE_INST_COUNT(SkImageFilter)
-SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs)
- : fInputCount(inputCount), fInputs(new SkImageFilter*[inputCount]) {
+SkImageFilter::SkImageFilter(int inputCount, SkImageFilter** inputs, const SkIRect* cropRect)
+ : fInputCount(inputCount),
+ fInputs(new SkImageFilter*[inputCount]),
+ fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
for (int i = 0; i < inputCount; ++i) {
fInputs[i] = inputs[i];
SkSafeRef(fInputs[i]);
}
}
-SkImageFilter::SkImageFilter(SkImageFilter* input)
- : fInputCount(1), fInputs(new SkImageFilter*[1]) {
+SkImageFilter::SkImageFilter(SkImageFilter* input, const SkIRect* cropRect)
+ : fInputCount(1),
+ fInputs(new SkImageFilter*[1]),
+ fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
fInputs[0] = input;
SkSafeRef(fInputs[0]);
}
-SkImageFilter::SkImageFilter(SkImageFilter* input1, SkImageFilter* input2)
- : fInputCount(2), fInputs(new SkImageFilter*[2]) {
+SkImageFilter::SkImageFilter(SkImageFilter* input1, SkImageFilter* input2, const SkIRect* cropRect)
+ : fInputCount(2), fInputs(new SkImageFilter*[2]),
+ fCropRect(cropRect ? *cropRect : SkIRect::MakeLargest()) {
fInputs[0] = input1;
fInputs[1] = input2;
SkSafeRef(fInputs[0]);
@@ -56,6 +61,7 @@ SkImageFilter::SkImageFilter(SkFlattenableReadBuffer& buffer)
fInputs[i] = NULL;
}
}
+ buffer.readIRect(&fCropRect);
}
void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
@@ -67,6 +73,7 @@ void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeFlattenable(input);
}
}
+ buffer.writeIRect(fCropRect);
}
bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
@@ -137,6 +144,10 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap*
#endif
}
+bool SkImageFilter::applyCropRect(SkIRect* rect) const {
+ return rect->intersect(fCropRect);
+}
+
bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
SkIRect* dst) {
*dst = src;
« no previous file with comments | « include/effects/SkColorFilterImageFilter.h ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698