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

Unified Diff: third_party/WebKit/Source/platform/graphics/filters/FEBoxReflect.cpp

Issue 1775013003: Implement -webkit-box-reflect as a filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make msvc dbg happy 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/filters/FEBoxReflect.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FEBoxReflect.cpp b/third_party/WebKit/Source/platform/graphics/filters/FEBoxReflect.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a7c41db1cf732ecd9d478e076ec50c07b1ad7b22
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/filters/FEBoxReflect.cpp
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/graphics/filters/FEBoxReflect.h"
+
+#include "platform/geometry/FloatRect.h"
+#include "platform/graphics/filters/SkiaImageFilterBuilder.h"
+#include "wtf/Assertions.h"
+
+namespace blink {
+
+PassRefPtrWillBeRawPtr<FEBoxReflect> FEBoxReflect::create(Filter* filter, ReflectionDirection direction, float offset)
+{
+ return adoptRefWillBeNoop(new FEBoxReflect(filter, direction, offset));
+}
+
+FEBoxReflect::FEBoxReflect(Filter* filter, ReflectionDirection direction, float offset)
+ : FilterEffect(filter)
+ , m_reflectionDirection(direction)
+ , m_offset(offset)
+{
+}
+
+FEBoxReflect::~FEBoxReflect()
+{
+}
+
+FloatRect FEBoxReflect::mapRect(const FloatRect& rect, bool forward)
+{
+ SkMatrix flipMatrix = SkiaImageFilterBuilder().matrixForBoxReflectFilter(
+ m_reflectionDirection, m_offset);
+ if (!forward) {
+ bool inverted = flipMatrix.invert(&flipMatrix);
+ DCHECK(inverted) << "box reflect matrix must be invertible";
+ }
+
+ SkRect reflection(rect);
+ flipMatrix.mapRect(&reflection);
+
+ FloatRect result = rect;
+ result.unite(reflection);
+ return result;
+}
+
+TextStream& FEBoxReflect::externalRepresentation(TextStream& ts, int indent) const
+{
+ // Only called for SVG layout tree printing.
+ ASSERT_NOT_REACHED();
+ return ts;
+}
+
+PassRefPtr<SkImageFilter> FEBoxReflect::createImageFilter(SkiaImageFilterBuilder& builder)
+{
+ RefPtr<SkImageFilter> input(builder.build(inputEffect(0), operatingColorSpace()));
+ return builder.buildBoxReflectFilter(m_reflectionDirection, m_offset, nullptr, input.get());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698