eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. |
| 3 | * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
staikos@webkit.org | 12821597 | 2009-07-30 18:08:23 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2008 Torch Mobile, Inc. |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef Pattern_h |
| 29 | #define Pattern_h |
| 30 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 31 | #include "AffineTransform.h" |
hyatt@apple.com | ffec3a4 | 2010-08-16 20:44:01 +0000 | [diff] [blame] | 32 | #include "Image.h" |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 33 | |
eric@webkit.org | 22794fd | 2008-08-28 12:04:40 +0000 | [diff] [blame] | 34 | #include <wtf/PassRefPtr.h> |
| 35 | #include <wtf/RefCounted.h> |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 36 | #include <wtf/RefPtr.h> |
| 37 | |
paroga@webkit.org | f226d9f | 2011-04-17 10:04:48 +0000 | [diff] [blame] | 38 | #if USE(CG) |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 39 | typedef struct CGPattern* CGPatternRef; |
| 40 | typedef CGPatternRef PlatformPatternPtr; |
paroga@webkit.org | 411b476 | 2011-04-16 10:37:01 +0000 | [diff] [blame] | 41 | #elif USE(CAIRO) |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 42 | #include <cairo.h> |
| 43 | typedef cairo_pattern_t* PlatformPatternPtr; |
paroga@webkit.org | cb73e5d | 2011-02-24 17:33:43 +0000 | [diff] [blame] | 44 | #elif USE(SKIA) |
eric@webkit.org | bac9376 | 2008-08-19 23:33:07 +0000 | [diff] [blame] | 45 | class SkShader; |
| 46 | typedef SkShader* PlatformPatternPtr; |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 47 | #elif PLATFORM(QT) |
| 48 | #include <QBrush> |
hausmann@webkit.org | f586440 | 2008-08-29 12:35:59 +0000 | [diff] [blame] | 49 | typedef QBrush PlatformPatternPtr; |
kevino@webkit.org | 141c460 | 2008-08-14 22:52:55 +0000 | [diff] [blame] | 50 | #elif PLATFORM(WX) |
| 51 | #if USE(WXGC) |
| 52 | class wxGraphicsBrush; |
| 53 | typedef wxGraphicsBrush* PlatformPatternPtr; |
| 54 | #else |
| 55 | class wxBrush; |
| 56 | typedef wxBrush* PlatformPatternPtr; |
| 57 | #endif // USE(WXGC) |
mjs@apple.com | acbcc28 | 2010-01-05 08:58:28 +0000 | [diff] [blame] | 58 | #elif OS(WINCE) |
staikos@webkit.org | 12821597 | 2009-07-30 18:08:23 +0000 | [diff] [blame] | 59 | typedef void* PlatformPatternPtr; |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 60 | #endif |
| 61 | |
| 62 | namespace WebCore { |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 63 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 64 | class AffineTransform; |
eric@webkit.org | 22794fd | 2008-08-28 12:04:40 +0000 | [diff] [blame] | 65 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 66 | class Pattern : public RefCounted<Pattern> { |
| 67 | public: |
hyatt@apple.com | ffec3a4 | 2010-08-16 20:44:01 +0000 | [diff] [blame] | 68 | static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY) |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 69 | { |
| 70 | return adoptRef(new Pattern(tileImage, repeatX, repeatY)); |
| 71 | } |
| 72 | virtual ~Pattern(); |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 73 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 74 | Image* tileImage() const { return m_tileImage.get(); } |
eric@webkit.org | 1afdbee | 2010-02-02 05:36:40 +0000 | [diff] [blame] | 75 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 76 | void platformDestroy(); |
| 77 | |
| 78 | // Pattern space is an abstract space that maps to the default user space by the transformation 'userSpaceTransformation' |
paroga@webkit.org | cb73e5d | 2011-02-24 17:33:43 +0000 | [diff] [blame] | 79 | #if USE(SKIA) |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 80 | PlatformPatternPtr platformPattern(const AffineTransform& userSpaceTransformation); |
eric@webkit.org | 1afdbee | 2010-02-02 05:36:40 +0000 | [diff] [blame] | 81 | #else |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 82 | PlatformPatternPtr createPlatformPattern(const AffineTransform& userSpaceTransformation) const; |
eric@webkit.org | 1afdbee | 2010-02-02 05:36:40 +0000 | [diff] [blame] | 83 | #endif |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 84 | void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformation); |
| 85 | void setPlatformPatternSpaceTransform(); |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 86 | |
laszlo.1.gombos@nokia.com | fe651e3 | 2010-03-23 14:37:02 +0000 | [diff] [blame] | 87 | bool repeatX() const { return m_repeatX; } |
| 88 | bool repeatY() const { return m_repeatY; } |
| 89 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 90 | private: |
hyatt@apple.com | ffec3a4 | 2010-08-16 20:44:01 +0000 | [diff] [blame] | 91 | Pattern(PassRefPtr<Image>, bool repeatX, bool repeatY); |
eric@webkit.org | 22794fd | 2008-08-28 12:04:40 +0000 | [diff] [blame] | 92 | |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 93 | RefPtr<Image> m_tileImage; |
| 94 | bool m_repeatX; |
| 95 | bool m_repeatY; |
| 96 | AffineTransform m_patternSpaceTransformation; |
| 97 | PlatformPatternPtr m_pattern; |
enne@google.com | af4e7a2 | 2012-02-29 01:12:57 +0000 | [diff] [blame] | 98 | #if USE(SKIA) |
enne@google.com | d89c65e | 2012-04-11 06:26:39 +0000 | [diff] [blame] | 99 | int m_externalMemoryAllocated; |
enne@google.com | af4e7a2 | 2012-02-29 01:12:57 +0000 | [diff] [blame] | 100 | #endif |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 101 | }; |
eric@webkit.org | f0124f6 | 2008-08-14 00:29:50 +0000 | [diff] [blame] | 102 | |
| 103 | } //namespace |
| 104 | |
| 105 | #endif |