Index: src/effects/SkFloodImageFilter.cpp |
diff --git a/src/effects/SkFloodImageFilter.cpp b/src/effects/SkFloodImageFilter.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..59792218f2f57f33e6004771e074a32f3b9b25e4 |
--- /dev/null |
+++ b/src/effects/SkFloodImageFilter.cpp |
@@ -0,0 +1,47 @@ |
+/* |
+ * Copyright 2013 The Android Open Source Project |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#include "SkFloodImageFilter.h" |
+#include "SkBitmap.h" |
+#include "SkCanvas.h" |
+#include "SkDevice.h" |
+#include "SkFlattenableBuffers.h" |
+#include "SkMatrix.h" |
+#include "SkPaint.h" |
+ |
+SkFloodImageFilter::SkFloodImageFilter(SkFlattenableReadBuffer& buffer) : INHERITED(buffer) { |
+ fColor = buffer.readColor(); |
+} |
+ |
+void SkFloodImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
+ this->INHERITED::flatten(buffer); |
+ buffer.writeColor(fColor); |
+} |
+ |
+bool SkFloodImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, |
+ SkBitmap* result, SkIPoint* offset) { |
+ if (!src.width() || !src.height()) { |
+ return false; |
+ } |
+ |
+ SkIRect bounds; |
+ src.getBounds(&bounds); |
+ if (!applyCropRect(&bounds, ctm)) { |
+ return false; |
+ } |
+ |
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height())); |
+ SkCanvas canvas(device.get()); |
+ SkPaint paint; |
+ paint.setColor(fColor); |
+ canvas.drawRect(SkRect::MakeWH(SkIntToScalar(src.width()), |
+ SkIntToScalar(src.height())), paint); |
+ *result = device->accessBitmap(false); |
+ offset->fX += bounds.left(); |
+ offset->fY += bounds.top(); |
+ return true; |
+} |