| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "core/platform/graphics/filters/FEColorMatrix.h" | 33 #include "core/platform/graphics/filters/FEColorMatrix.h" |
| 34 #include "core/platform/graphics/filters/FEComponentTransfer.h" | 34 #include "core/platform/graphics/filters/FEComponentTransfer.h" |
| 35 #include "core/platform/graphics/filters/FEDropShadow.h" | 35 #include "core/platform/graphics/filters/FEDropShadow.h" |
| 36 #include "core/platform/graphics/filters/FEGaussianBlur.h" | 36 #include "core/platform/graphics/filters/FEGaussianBlur.h" |
| 37 #include "core/platform/graphics/filters/FEMerge.h" | 37 #include "core/platform/graphics/filters/FEMerge.h" |
| 38 #include "core/rendering/RenderLayer.h" | 38 #include "core/rendering/RenderLayer.h" |
| 39 | 39 |
| 40 #include <algorithm> | 40 #include <algorithm> |
| 41 #include <wtf/MathExtras.h> | 41 #include <wtf/MathExtras.h> |
| 42 | 42 |
| 43 #if USE(3D_GRAPHICS) | |
| 44 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h" | 43 #include "core/platform/graphics/filters/custom/CustomFilterGlobalContext.h" |
| 45 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h" | 44 #include "core/platform/graphics/filters/custom/CustomFilterOperation.h" |
| 46 #include "core/platform/graphics/filters/custom/CustomFilterProgram.h" | 45 #include "core/platform/graphics/filters/custom/CustomFilterProgram.h" |
| 47 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h" | 46 #include "core/platform/graphics/filters/custom/CustomFilterValidatedProgram.h" |
| 48 #include "core/platform/graphics/filters/custom/FECustomFilter.h" | 47 #include "core/platform/graphics/filters/custom/FECustomFilter.h" |
| 49 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h
" | 48 #include "core/platform/graphics/filters/custom/ValidatedCustomFilterOperation.h
" |
| 50 #include "core/rendering/RenderView.h" | 49 #include "core/rendering/RenderView.h" |
| 51 #endif | |
| 52 | 50 |
| 53 #if ENABLE(SVG) | 51 #if ENABLE(SVG) |
| 54 #include "core/loader/cache/CachedSVGDocument.h" | 52 #include "core/loader/cache/CachedSVGDocument.h" |
| 55 #include "core/loader/cache/CachedSVGDocumentReference.h" | 53 #include "core/loader/cache/CachedSVGDocumentReference.h" |
| 56 #include "core/platform/graphics/filters/SourceAlpha.h" | 54 #include "core/platform/graphics/filters/SourceAlpha.h" |
| 57 #include "core/svg/SVGElement.h" | 55 #include "core/svg/SVGElement.h" |
| 58 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" | 56 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" |
| 59 #endif | 57 #endif |
| 60 | 58 |
| 61 namespace WebCore { | 59 namespace WebCore { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 76 } | 74 } |
| 77 | 75 |
| 78 inline bool isFilterSizeValid(FloatRect rect) | 76 inline bool isFilterSizeValid(FloatRect rect) |
| 79 { | 77 { |
| 80 if (rect.width() < 0 || rect.width() > kMaxFilterSize | 78 if (rect.width() < 0 || rect.width() > kMaxFilterSize |
| 81 || rect.height() < 0 || rect.height() > kMaxFilterSize) | 79 || rect.height() < 0 || rect.height() > kMaxFilterSize) |
| 82 return false; | 80 return false; |
| 83 return true; | 81 return true; |
| 84 } | 82 } |
| 85 | 83 |
| 86 #if USE(3D_GRAPHICS) | |
| 87 static PassRefPtr<FECustomFilter> createCustomFilterEffect(Filter* filter, Docum
ent* document, ValidatedCustomFilterOperation* operation) | 84 static PassRefPtr<FECustomFilter> createCustomFilterEffect(Filter* filter, Docum
ent* document, ValidatedCustomFilterOperation* operation) |
| 88 { | 85 { |
| 89 if (!document) | 86 if (!document) |
| 90 return 0; | 87 return 0; |
| 91 | 88 |
| 92 CustomFilterGlobalContext* globalContext = document->renderView()->customFil
terGlobalContext(); | 89 CustomFilterGlobalContext* globalContext = document->renderView()->customFil
terGlobalContext(); |
| 93 globalContext->prepareContextIfNeeded(document->view()->hostWindow()); | 90 globalContext->prepareContextIfNeeded(document->view()->hostWindow()); |
| 94 if (!globalContext->context()) | 91 if (!globalContext->context()) |
| 95 return 0; | 92 return 0; |
| 96 | 93 |
| 97 return FECustomFilter::create(filter, globalContext->context(), operation->v
alidatedProgram(), operation->parameters(), | 94 return FECustomFilter::create(filter, globalContext->context(), operation->v
alidatedProgram(), operation->parameters(), |
| 98 operation->meshRows(), operation->meshColumns(), operation->meshType())
; | 95 operation->meshRows(), operation->meshColumns(), operation->meshType())
; |
| 99 } | 96 } |
| 100 #endif | |
| 101 | 97 |
| 102 FilterEffectRenderer::FilterEffectRenderer() | 98 FilterEffectRenderer::FilterEffectRenderer() |
| 103 : m_graphicsBufferAttached(false) | 99 : m_graphicsBufferAttached(false) |
| 104 , m_hasFilterThatMovesPixels(false) | 100 , m_hasFilterThatMovesPixels(false) |
| 105 , m_hasCustomShaderFilter(false) | 101 , m_hasCustomShaderFilter(false) |
| 106 { | 102 { |
| 107 setFilterResolution(FloatSize(1, 1)); | 103 setFilterResolution(FloatSize(1, 1)); |
| 108 m_sourceGraphic = SourceGraphic::create(this); | 104 m_sourceGraphic = SourceGraphic::create(this); |
| 109 } | 105 } |
| 110 | 106 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 float stdDeviation = floatValueForLength(blurOperation->stdDeviation
(), 0); | 324 float stdDeviation = floatValueForLength(blurOperation->stdDeviation
(), 0); |
| 329 effect = FEGaussianBlur::create(this, stdDeviation, stdDeviation); | 325 effect = FEGaussianBlur::create(this, stdDeviation, stdDeviation); |
| 330 break; | 326 break; |
| 331 } | 327 } |
| 332 case FilterOperation::DROP_SHADOW: { | 328 case FilterOperation::DROP_SHADOW: { |
| 333 DropShadowFilterOperation* dropShadowOperation = static_cast<DropSha
dowFilterOperation*>(filterOperation); | 329 DropShadowFilterOperation* dropShadowOperation = static_cast<DropSha
dowFilterOperation*>(filterOperation); |
| 334 effect = FEDropShadow::create(this, dropShadowOperation->stdDeviatio
n(), dropShadowOperation->stdDeviation(), | 330 effect = FEDropShadow::create(this, dropShadowOperation->stdDeviatio
n(), dropShadowOperation->stdDeviation(), |
| 335 dropShadowOperation->x(), dropSh
adowOperation->y(), dropShadowOperation->color(), 1); | 331 dropShadowOperation->x(), dropSh
adowOperation->y(), dropShadowOperation->color(), 1); |
| 336 break; | 332 break; |
| 337 } | 333 } |
| 338 #if USE(3D_GRAPHICS) | |
| 339 case FilterOperation::CUSTOM: | 334 case FilterOperation::CUSTOM: |
| 340 // CUSTOM operations are always converted to VALIDATED_CUSTOM before
getting here. | 335 // CUSTOM operations are always converted to VALIDATED_CUSTOM before
getting here. |
| 341 // The conversion happens in RenderLayer::computeFilterOperations. | 336 // The conversion happens in RenderLayer::computeFilterOperations. |
| 342 ASSERT_NOT_REACHED(); | 337 ASSERT_NOT_REACHED(); |
| 343 break; | 338 break; |
| 344 case FilterOperation::VALIDATED_CUSTOM: { | 339 case FilterOperation::VALIDATED_CUSTOM: { |
| 345 ValidatedCustomFilterOperation* customFilterOperation = static_cast<
ValidatedCustomFilterOperation*>(filterOperation); | 340 ValidatedCustomFilterOperation* customFilterOperation = static_cast<
ValidatedCustomFilterOperation*>(filterOperation); |
| 346 Document* document = renderer ? renderer->document() : 0; | 341 Document* document = renderer ? renderer->document() : 0; |
| 347 effect = createCustomFilterEffect(this, document, customFilterOperat
ion); | 342 effect = createCustomFilterEffect(this, document, customFilterOperat
ion); |
| 348 if (effect) | 343 if (effect) |
| 349 m_hasCustomShaderFilter = true; | 344 m_hasCustomShaderFilter = true; |
| 350 break; | 345 break; |
| 351 } | 346 } |
| 352 #endif | |
| 353 default: | 347 default: |
| 354 break; | 348 break; |
| 355 } | 349 } |
| 356 | 350 |
| 357 if (effect) { | 351 if (effect) { |
| 358 // Unlike SVG, filters applied here should not clip to their primiti
ve subregions. | 352 // Unlike SVG, filters applied here should not clip to their primiti
ve subregions. |
| 359 effect->setClipsToBounds(false); | 353 effect->setClipsToBounds(false); |
| 360 effect->setOperatingColorSpace(ColorSpaceDeviceRGB); | 354 effect->setOperatingColorSpace(ColorSpaceDeviceRGB); |
| 361 | 355 |
| 362 if (filterOperation->getOperationType() != FilterOperation::REFERENC
E) { | 356 if (filterOperation->getOperationType() != FilterOperation::REFERENC
E) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 495 |
| 502 m_savedGraphicsContext->drawImageBuffer(filter->output(), m_renderLayer->ren
derer()->style()->colorSpace(), pixelSnappedIntRect(destRect), CompositeSourceOv
er); | 496 m_savedGraphicsContext->drawImageBuffer(filter->output(), m_renderLayer->ren
derer()->style()->colorSpace(), pixelSnappedIntRect(destRect), CompositeSourceOv
er); |
| 503 | 497 |
| 504 filter->clearIntermediateResults(); | 498 filter->clearIntermediateResults(); |
| 505 | 499 |
| 506 return m_savedGraphicsContext; | 500 return m_savedGraphicsContext; |
| 507 } | 501 } |
| 508 | 502 |
| 509 } // namespace WebCore | 503 } // namespace WebCore |
| 510 | 504 |
| OLD | NEW |