From 2e6d435a42679ce722f6910b0596905d53c95d49 Mon Sep 17 00:00:00 2001 From: ap Date: Mon, 24 Jul 2006 17:26:52 +0000 Subject: [PATCH] Fix by Dave MacLachlan, reviewed by Darin and Alexey. Fix for: and Test: svg/custom/non-opaque-filters.svg * kcanvas/device/quartz/KCanvasFilterQuartz.mm: (WebCore::KCanvasFilterQuartz::prepareFilter): We create an autorelease pool so we can control the deallocation of the CIContext that we're creating. The CIContext retains the CGContext that you pass it internally so when the CIContext is released, the CGContext is released as well. This is all fine and dandy unless you wrap the creation of the CIFilter with a pair of CGBegin/EndTransparencyLayer calls which swap the context out from underneath you. So if you start with context A, CGBeginTransparencyLayer swaps it out and gives you B. You create a CIFilter with it and add a reference to B. CGEndTransparencyLayer swaps out B and gives you back A. Autorelease pool comes and cleans up the Filter, and calls release on A, but A never got the refcount in the first place. B did. BOOM! So we create a pool, then do a retain, then release the pool so that we don't have to worry about the pool releasing it at a later time. See for reduction of CGEndTransparencyLayer case git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15603 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 12 ++++++++ .../non-opaque-filters-expected.checksum | 1 + .../custom/non-opaque-filters-expected.png | Bin 0 -> 5828 bytes .../custom/non-opaque-filters-expected.txt | 9 ++++++ LayoutTests/svg/custom/non-opaque-filters.svg | 13 +++++++++ WebCore/ChangeLog | 26 ++++++++++++++++++ .../device/quartz/KCanvasFilterQuartz.mm | 10 +++++++ 7 files changed, 71 insertions(+) create mode 100644 LayoutTests/svg/custom/non-opaque-filters-expected.checksum create mode 100644 LayoutTests/svg/custom/non-opaque-filters-expected.png create mode 100644 LayoutTests/svg/custom/non-opaque-filters-expected.txt create mode 100644 LayoutTests/svg/custom/non-opaque-filters.svg diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 315670c1338f..92abfb9a1b82 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2006-07-24 Dave MacLachlan + + Reviewed by Darin and Alexey. + + Test for: + and + + * svg/custom/non-opaque-filters-expected.checksum: Added. + * svg/custom/non-opaque-filters-expected.png: Added. + * svg/custom/non-opaque-filters-expected.txt: Added. + * svg/custom/non-opaque-filters.svg: Added. + 2006-07-24 Mitz Pettel Reviewed by Hyatt. diff --git a/LayoutTests/svg/custom/non-opaque-filters-expected.checksum b/LayoutTests/svg/custom/non-opaque-filters-expected.checksum new file mode 100644 index 000000000000..bef0c814a005 --- /dev/null +++ b/LayoutTests/svg/custom/non-opaque-filters-expected.checksum @@ -0,0 +1 @@ +02d502476ee4f6dc4f5cfc3de57131d0 \ No newline at end of file diff --git a/LayoutTests/svg/custom/non-opaque-filters-expected.png b/LayoutTests/svg/custom/non-opaque-filters-expected.png new file mode 100644 index 0000000000000000000000000000000000000000..fa92cdd4afd2cc628c77a5d0217dac3c5b7f7f73 GIT binary patch literal 5828 zcmeI0`%_bQ8pe;8f?EsJaV!=~(Aq8Ap-3H!7eb6KR&*#JmqRom#1;ii3Q^&33khCY zSrv#~6_jfg1vw#!2q!6*1T6wq2-HFnNC=TqZV4oENdh4Wo7jI~f86eHemwI%^S;mL z`@YXSbFLl>33Phb?Ogx>oQ@tj6b=AuwgSNFJJXMojI(!s5K>LxEGD9Nn5(|WHcK*2QY|&lDGi}Yf)`PFBj^fJG<_2Aj5Z1N% zHO82%3T>^=seh8+0Pk-;r-|4JSnp^zcl$E#FO z+iJ-*!)vbS45xZO4PmRu=A|`H9t-c%vU72nSqyzFd3tu?m%!5K_}sk}nY#>o6R7=m zrCHO@E~i?t`}*nc0f0`DKI!Sh`C-lB)P1l2eRD_k&Vcqv5M;HZB*&ac`R;x6WA4Tu zMp83{6@CWFPMy1;YSDnVwUm}&HBfjktj$xhYlmMCep-hxsEoyKA6W&>Kl5pikP}NR z?D*|%4XLFjwnsjFL4-9)zx#TlUv`o%fyYKQ!pudp4|{o=MZ+R5#O8hU#gifVn<%B} zXAU%e38T46^A7{Ty0I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G5_u{T4FkzxzO)IohfS5&uquV&}hu2 zq^#NYOlX>o{?T~BZ|rfb-LE5gC?RD4(@7aHokow=e}-Z3+Tj8anzR&ZcWJx7Pt&G~ zYI9f|yV0XrF%cXEK{G9;$r61Aqj1IZb$-n~!yt%$pu5pHe07W3K29dFhFwjI;G7{v zv^sBzViTey2#Z7vl73!Y$qa_tU-+sQo^{Acptw-W-=qCrN+THgj*%nKA{&d4zPr{Wi z_Si>(@%5mqn(vy#{$9LZ(|4~*JFEL9l%8e&afJG+=u5~->*j4_?X3;@)^FxVOTb#- zwMRfe2Nx9#0rhw~Ix3ckyOn8QgDc&0MA-1b`<0FHhca)|rSlb8MjA%|f` literal 0 HcmV?d00001 diff --git a/LayoutTests/svg/custom/non-opaque-filters-expected.txt b/LayoutTests/svg/custom/non-opaque-filters-expected.txt new file mode 100644 index 000000000000..7095e094d54b --- /dev/null +++ b/LayoutTests/svg/custom/non-opaque-filters-expected.txt @@ -0,0 +1,9 @@ +KCanvasResource {id="gblur" [type=FILTER] [bounding box=at (-0.10,-0.10) size 1.20x1.20] [effect bounding box mode=0] [effects=[[type=GAUSSIAN-BLUR] [subregion="at (0,0) size 800x600"] [std dev. x=0.00 y=0.00]]]} +layer at (0,0) size 800x600 + RenderView at (0,0) size 800x600 + KCanvasContainer {svg} at (0,0) size 87x40 + KCanvasContainer {g} at (0,0) size 87x40 [opacity=0.50] + KCanvasItem {rect} at (0,0) size 87x40 [fill={[type=SOLID] [color=#008000]}] [filter=#gblur] [data="M0.00,0.00L87.00,0.00L87.00,40.00L0.00,40.00"] + RenderSVGText {text} at (0,0) size 785x18 + RenderText {#text} at (0,0) size 139x18 + text run at (0,0) width 139: "This should not crash." diff --git a/LayoutTests/svg/custom/non-opaque-filters.svg b/LayoutTests/svg/custom/non-opaque-filters.svg new file mode 100644 index 000000000000..49c0dd288261 --- /dev/null +++ b/LayoutTests/svg/custom/non-opaque-filters.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + This should not crash. + diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 4761cfda4bc9..c27320a52736 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,29 @@ +2006-07-24 Dave MacLachlan + + Reviewed by Darin and Alexey. + + Fix for: + and + + Test: svg/custom/non-opaque-filters.svg + + * kcanvas/device/quartz/KCanvasFilterQuartz.mm: + (WebCore::KCanvasFilterQuartz::prepareFilter): + We create an autorelease pool so we can control the deallocation of the + CIContext that we're creating. The CIContext retains the CGContext that + you pass it internally so when the CIContext is released, the + CGContext is released as well. + This is all fine and dandy unless you wrap the creation of the CIFilter + with a pair of CGBegin/EndTransparencyLayer calls which swap the context + out from underneath you. So if you start with context A, + CGBeginTransparencyLayer swaps it out and gives you B. You create a CIFilter + with it and add a reference to B. CGEndTransparencyLayer swaps out B and + gives you back A. Autorelease pool comes and cleans up the Filter, and calls + release on A, but A never got the refcount in the first place. B did. BOOM! + So we create a pool, then do a retain, then release the pool so that we + don't have to worry about the pool releasing it at a later time. + See for reduction of CGEndTransparencyLayer case + 2006-07-24 Mitz Pettel Reviewed by Hyatt. diff --git a/WebCore/kcanvas/device/quartz/KCanvasFilterQuartz.mm b/WebCore/kcanvas/device/quartz/KCanvasFilterQuartz.mm index d9b96cd1ec66..66c577618201 100644 --- a/WebCore/kcanvas/device/quartz/KCanvasFilterQuartz.mm +++ b/WebCore/kcanvas/device/quartz/KCanvasFilterQuartz.mm @@ -1,5 +1,6 @@ /* * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Dave MacLachlan (dmaclach@mac.com) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -115,7 +116,16 @@ void KCanvasFilterQuartz::prepareFilter(const FloatRect &bbox) if (useSoftware) contextOptions = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], kCIContextUseSoftwareRenderer, nil]; + // Use of CGBegin/EndTransparencyLayer around this call causes over release + // of cgContext due to it being created on an autorelease pool, and released + // after CGEndTransparencyLayer. Create local pool to fix. + // + // + // + NSAutoreleasePool *filterContextPool = [[NSAutoreleasePool alloc] init]; m_filterCIContext = HardRetain([CIContext contextWithCGContext:cgContext options:contextOptions]); + [filterContextPool drain]; + m_filterCGLayer = [m_filterCIContext createCGLayerWithSize:CGRect(bbox).size info:NULL]; KRenderingDeviceContext *filterContext = new KRenderingDeviceContextQuartz(CGLayerGetContext(m_filterCGLayer)); -- 2.36.0