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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "platform/graphics/BoxReflection.h"
6
7 #include "platform/geometry/FloatRect.h"
8 #include "platform/graphics/skia/SkiaUtils.h"
9 #include "third_party/skia/include/core/SkImageFilter.h"
10 #include "third_party/skia/include/core/SkMatrix.h"
11 #include "third_party/skia/include/core/SkPicture.h"
12 #include "third_party/skia/include/core/SkRefCnt.h"
13 #include "third_party/skia/include/core/SkXfermode.h"
14 #include "third_party/skia/include/effects/SkPictureImageFilter.h"
15 #include "third_party/skia/include/effects/SkXfermodeImageFilter.h"
16
17 #include <utility>
18
19 namespace blink {
20
21 SkMatrix BoxReflection::reflectionMatrix() const
22 {
23 SkMatrix flipMatrix;
24 switch (m_direction) {
25 case VerticalReflection:
26 flipMatrix.setScale(1, -1);
27 flipMatrix.postTranslate(0, m_offset);
28 break;
29 case HorizontalReflection:
30 flipMatrix.setScale(-1, 1);
31 flipMatrix.postTranslate(m_offset, 0);
32 break;
33 default:
34 // MSVC requires that SkMatrix be initialized in this unreachable case.
35 NOTREACHED();
36 flipMatrix.reset();
37 break;
38 }
39 return flipMatrix;
40 }
41
42 FloatRect BoxReflection::mapRect(const FloatRect& rect) const
43 {
44 SkRect reflection(rect);
45 reflectionMatrix().mapRect(&reflection);
46 FloatRect result = rect;
47 result.unite(reflection);
48 return result;
49 }
50
51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698