OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 static inline void lastMatrixRow(Vector<float>& parameters) | 60 static inline void lastMatrixRow(Vector<float>& parameters) |
61 { | 61 { |
62 parameters.append(0); | 62 parameters.append(0); |
63 parameters.append(0); | 63 parameters.append(0); |
64 parameters.append(0); | 64 parameters.append(0); |
65 parameters.append(1); | 65 parameters.append(1); |
66 parameters.append(0); | 66 parameters.append(0); |
67 } | 67 } |
68 | 68 |
69 inline bool isFilterSizeValid(FloatRect rect) | |
70 { | |
71 if (rect.width() < 0 || rect.width() > kMaxFilterSize | |
72 || rect.height() < 0 || rect.height() > kMaxFilterSize) | |
73 return false; | |
74 return true; | |
75 } | |
76 | |
77 FilterEffectRenderer::FilterEffectRenderer() | 69 FilterEffectRenderer::FilterEffectRenderer() |
78 : Filter(AffineTransform()) | 70 : Filter(AffineTransform()) |
79 , m_graphicsBufferAttached(false) | 71 , m_graphicsBufferAttached(false) |
80 , m_hasFilterThatMovesPixels(false) | 72 , m_hasFilterThatMovesPixels(false) |
81 , m_hasCustomShaderFilter(false) | 73 , m_hasCustomShaderFilter(false) |
82 { | 74 { |
83 m_sourceGraphic = SourceGraphic::create(this); | 75 m_sourceGraphic = SourceGraphic::create(this); |
84 } | 76 } |
85 | 77 |
86 FilterEffectRenderer::~FilterEffectRenderer() | 78 FilterEffectRenderer::~FilterEffectRenderer() |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // If we didn't make any effects, tell our caller we are not valid | 251 // If we didn't make any effects, tell our caller we are not valid |
260 if (!m_lastEffect.get()) | 252 if (!m_lastEffect.get()) |
261 return false; | 253 return false; |
262 | 254 |
263 return true; | 255 return true; |
264 } | 256 } |
265 | 257 |
266 bool FilterEffectRenderer::updateBackingStoreRect(const FloatRect& floatFilterRe
ct) | 258 bool FilterEffectRenderer::updateBackingStoreRect(const FloatRect& floatFilterRe
ct) |
267 { | 259 { |
268 IntRect filterRect = enclosingIntRect(floatFilterRect); | 260 IntRect filterRect = enclosingIntRect(floatFilterRect); |
269 if (!filterRect.isEmpty() && isFilterSizeValid(filterRect)) { | 261 if (!filterRect.isEmpty() && FilterEffect::isFilterSizeValid(filterRect)) { |
270 FloatRect currentSourceRect = sourceImageRect(); | 262 FloatRect currentSourceRect = sourceImageRect(); |
271 if (filterRect != currentSourceRect) { | 263 if (filterRect != currentSourceRect) { |
272 setSourceImageRect(filterRect); | 264 setSourceImageRect(filterRect); |
273 return true; | 265 return true; |
274 } | 266 } |
275 } | 267 } |
276 return false; | 268 return false; |
277 } | 269 } |
278 | 270 |
279 void FilterEffectRenderer::allocateBackingStoreIfNeeded() | 271 void FilterEffectRenderer::allocateBackingStoreIfNeeded() |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 } | 362 } |
371 | 363 |
372 GraphicsContext* FilterEffectRendererHelper::beginFilterEffect(GraphicsContext*
oldContext) | 364 GraphicsContext* FilterEffectRendererHelper::beginFilterEffect(GraphicsContext*
oldContext) |
373 { | 365 { |
374 ASSERT(m_renderLayer); | 366 ASSERT(m_renderLayer); |
375 | 367 |
376 FilterEffectRenderer* filter = m_renderLayer->filterRenderer(); | 368 FilterEffectRenderer* filter = m_renderLayer->filterRenderer(); |
377 filter->allocateBackingStoreIfNeeded(); | 369 filter->allocateBackingStoreIfNeeded(); |
378 // Paint into the context that represents the SourceGraphic of the filter. | 370 // Paint into the context that represents the SourceGraphic of the filter. |
379 GraphicsContext* sourceGraphicsContext = filter->inputContext(); | 371 GraphicsContext* sourceGraphicsContext = filter->inputContext(); |
380 if (!sourceGraphicsContext || !isFilterSizeValid(filter->absoluteFilterRegio
n())) { | 372 if (!sourceGraphicsContext || !FilterEffect::isFilterSizeValid(filter->absol
uteFilterRegion())) { |
381 // Disable the filters and continue. | 373 // Disable the filters and continue. |
382 m_haveFilterEffect = false; | 374 m_haveFilterEffect = false; |
383 return oldContext; | 375 return oldContext; |
384 } | 376 } |
385 | 377 |
386 m_savedGraphicsContext = oldContext; | 378 m_savedGraphicsContext = oldContext; |
387 | 379 |
388 // Translate the context so that the contents of the layer is captuterd in t
he offscreen memory buffer. | 380 // Translate the context so that the contents of the layer is captuterd in t
he offscreen memory buffer. |
389 sourceGraphicsContext->save(); | 381 sourceGraphicsContext->save(); |
390 // FIXME: can we just use sourceImageRect for everything, and get rid of | 382 // FIXME: can we just use sourceImageRect for everything, and get rid of |
(...skipping 17 matching lines...) Expand all Loading... |
408 // Get the filtered output and draw it in place. | 400 // Get the filtered output and draw it in place. |
409 m_savedGraphicsContext->drawImageBuffer(filter->output(), filter->outputRect
(), CompositeSourceOver); | 401 m_savedGraphicsContext->drawImageBuffer(filter->output(), filter->outputRect
(), CompositeSourceOver); |
410 | 402 |
411 filter->clearIntermediateResults(); | 403 filter->clearIntermediateResults(); |
412 | 404 |
413 return m_savedGraphicsContext; | 405 return m_savedGraphicsContext; |
414 } | 406 } |
415 | 407 |
416 } // namespace WebCore | 408 } // namespace WebCore |
417 | 409 |
OLD | NEW |