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

Unified Diff: third_party/WebKit/Source/platform/graphics/BoxReflection.cpp

Issue 1870793004: Move common logic between BoxReflectFilterOperation and FEBoxReflect into BoxReflection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-filter-outsets-2
Patch Set: merge with master Created 4 years, 8 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/BoxReflection.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/BoxReflection.cpp b/third_party/WebKit/Source/platform/graphics/BoxReflection.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64e36f4e8a22848fb720c159cad639ebfef275ab
--- /dev/null
+++ b/third_party/WebKit/Source/platform/graphics/BoxReflection.cpp
@@ -0,0 +1,51 @@
+// 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/BoxReflection.h"
+
+#include "platform/geometry/FloatRect.h"
+#include "platform/graphics/skia/SkiaUtils.h"
+#include "third_party/skia/include/core/SkImageFilter.h"
+#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkPicture.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
+#include "third_party/skia/include/core/SkXfermode.h"
+#include "third_party/skia/include/effects/SkPictureImageFilter.h"
+#include "third_party/skia/include/effects/SkXfermodeImageFilter.h"
+
+#include <utility>
+
+namespace blink {
+
+SkMatrix BoxReflection::reflectionMatrix() const
+{
+ SkMatrix flipMatrix;
+ switch (m_direction) {
+ case VerticalReflection:
+ flipMatrix.setScale(1, -1);
+ flipMatrix.postTranslate(0, m_offset);
+ break;
+ case HorizontalReflection:
+ flipMatrix.setScale(-1, 1);
+ flipMatrix.postTranslate(m_offset, 0);
+ break;
+ default:
+ // MSVC requires that SkMatrix be initialized in this unreachable case.
+ NOTREACHED();
+ flipMatrix.reset();
+ break;
+ }
+ return flipMatrix;
+}
+
+FloatRect BoxReflection::mapRect(const FloatRect& rect) const
+{
+ SkRect reflection(rect);
+ reflectionMatrix().mapRect(&reflection);
+ FloatRect result = rect;
+ result.unite(reflection);
+ return result;
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698