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

Side by Side Diff: Source/platform/graphics/filters/FilterEffect.cpp

Issue 150973004: Fixes the rendering of a SVG filter (e.g. feFlood) by testing against total (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added rebaseline test. Created 6 years, 10 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
« no previous file with comments | « Source/platform/graphics/filters/FilterEffect.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
5 * Copyright (C) 2012 University of Szeged 5 * Copyright (C) 2012 University of Szeged
6 * Copyright (C) 2013 Google Inc. All rights reserved. 6 * Copyright (C) 2013 Google Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 18 matching lines...) Expand all
29 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 29 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
30 #include "platform/graphics/filters/Filter.h" 30 #include "platform/graphics/filters/Filter.h"
31 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" 31 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h"
32 32
33 #if HAVE(ARM_NEON_INTRINSICS) 33 #if HAVE(ARM_NEON_INTRINSICS)
34 #include <arm_neon.h> 34 #include <arm_neon.h>
35 #endif 35 #endif
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 static const float kMaxFilterArea = 4096 * 4096;
40
39 FilterEffect::FilterEffect(Filter* filter) 41 FilterEffect::FilterEffect(Filter* filter)
40 : m_alphaImage(false) 42 : m_alphaImage(false)
41 , m_filter(filter) 43 , m_filter(filter)
42 , m_hasX(false) 44 , m_hasX(false)
43 , m_hasY(false) 45 , m_hasY(false)
44 , m_hasWidth(false) 46 , m_hasWidth(false)
45 , m_hasHeight(false) 47 , m_hasHeight(false)
46 , m_clipsToBounds(true) 48 , m_clipsToBounds(true)
47 , m_operatingColorSpace(ColorSpaceLinearRGB) 49 , m_operatingColorSpace(ColorSpaceLinearRGB)
48 , m_resultColorSpace(ColorSpaceDeviceRGB) 50 , m_resultColorSpace(ColorSpaceDeviceRGB)
49 { 51 {
50 ASSERT(m_filter); 52 ASSERT(m_filter);
51 } 53 }
52 54
53 FilterEffect::~FilterEffect() 55 FilterEffect::~FilterEffect()
54 { 56 {
55 } 57 }
56 58
57 inline bool isFilterSizeValid(IntRect rect) 59 float FilterEffect::maxFilterArea()
58 { 60 {
59 if (rect.width() < 0 || rect.width() > kMaxFilterSize 61 return kMaxFilterArea;
60 || rect.height() < 0 || rect.height() > kMaxFilterSize) 62 }
63
64 bool FilterEffect::isFilterSizeValid(const FloatRect& rect)
65 {
66 if (rect.width() < 0 || rect.height() < 0
67 || (rect.height() * rect.width() > kMaxFilterArea))
61 return false; 68 return false;
69
62 return true; 70 return true;
63 } 71 }
64 72
73
74 bool FilterEffect::isFilterSizeValid(const IntRect& rect)
75 {
76 return isFilterSizeValid(FloatRect(rect));
77 }
78
65 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect) 79 FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequ estedRect)
66 { 80 {
67 FloatRect requestedRect = originalRequestedRect; 81 FloatRect requestedRect = originalRequestedRect;
68 // Filters in SVG clip to primitive subregion, while CSS doesn't. 82 // Filters in SVG clip to primitive subregion, while CSS doesn't.
69 if (m_clipsToBounds) 83 if (m_clipsToBounds)
70 requestedRect.intersect(maxEffectRect()); 84 requestedRect.intersect(maxEffectRect());
71 85
72 // We may be called multiple times if result is used more than once. Return 86 // We may be called multiple times if result is used more than once. Return
73 // quickly if if nothing new is required. 87 // quickly if if nothing new is required.
74 if (absolutePaintRect().contains(enclosingIntRect(requestedRect))) 88 if (absolutePaintRect().contains(enclosingIntRect(requestedRect)))
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 575 }
562 if (hasHeight()) { 576 if (hasHeight()) {
563 rect.fBottom = rect.fTop + boundaries.height(); 577 rect.fBottom = rect.fTop + boundaries.height();
564 flags |= SkImageFilter::CropRect::kHasBottom_CropEdge; 578 flags |= SkImageFilter::CropRect::kHasBottom_CropEdge;
565 } 579 }
566 rect = filter()->mapLocalRectToAbsoluteRect(rect); 580 rect = filter()->mapLocalRectToAbsoluteRect(rect);
567 return SkImageFilter::CropRect(rect, flags); 581 return SkImageFilter::CropRect(rect, flags);
568 } 582 }
569 583
570 } // namespace WebCore 584 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/filters/FilterEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698