OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
4 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
5 * Copyright (C) 2013 Google, Inc. All rights reserved. | 5 * Copyright (C) 2013 Google, Inc. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 public: | 48 public: |
49 enum RepeatMode { | 49 enum RepeatMode { |
50 RepeatModeX = 1 << 0, | 50 RepeatModeX = 1 << 0, |
51 RepeatModeY = 1 << 1, | 51 RepeatModeY = 1 << 1, |
52 | 52 |
53 RepeatModeNone = 0, | 53 RepeatModeNone = 0, |
54 RepeatModeXY = RepeatModeX | RepeatModeY | 54 RepeatModeXY = RepeatModeX | RepeatModeY |
55 }; | 55 }; |
56 | 56 |
57 static PassRefPtr<Pattern> createImagePattern(PassRefPtr<Image>, RepeatMode
= RepeatModeXY); | 57 static PassRefPtr<Pattern> createImagePattern(PassRefPtr<Image>, RepeatMode
= RepeatModeXY); |
58 static PassRefPtr<Pattern> createPicturePattern(PassRefPtr<SkPicture>, | 58 static PassRefPtr<Pattern> createPicturePattern(sk_sp<SkPicture>, |
59 RepeatMode = RepeatModeXY); | 59 RepeatMode = RepeatModeXY); |
60 virtual ~Pattern(); | 60 virtual ~Pattern(); |
61 | 61 |
62 void applyToPaint(SkPaint&, const SkMatrix&); | 62 void applyToPaint(SkPaint&, const SkMatrix&); |
63 | 63 |
64 bool isRepeatX() const { return m_repeatMode & RepeatModeX; } | 64 bool isRepeatX() const { return m_repeatMode & RepeatModeX; } |
65 bool isRepeatY() const { return m_repeatMode & RepeatModeY; } | 65 bool isRepeatY() const { return m_repeatMode & RepeatModeY; } |
66 bool isRepeatXY() const { return m_repeatMode == RepeatModeXY; } | 66 bool isRepeatXY() const { return m_repeatMode == RepeatModeXY; } |
67 | 67 |
68 virtual bool isTextureBacked() const { return false; } | 68 virtual bool isTextureBacked() const { return false; } |
69 | 69 |
70 protected: | 70 protected: |
71 virtual sk_sp<SkShader> createShader(const SkMatrix&) = 0; | 71 virtual sk_sp<SkShader> createShader(const SkMatrix&) = 0; |
72 virtual bool isLocalMatrixChanged(const SkMatrix&) const; | 72 virtual bool isLocalMatrixChanged(const SkMatrix&) const; |
73 | 73 |
74 void adjustExternalMemoryAllocated(int64_t delta); | 74 void adjustExternalMemoryAllocated(int64_t delta); |
75 | 75 |
76 RepeatMode m_repeatMode; | 76 RepeatMode m_repeatMode; |
77 | 77 |
78 Pattern(RepeatMode, int64_t externalMemoryAllocated = 0); | 78 Pattern(RepeatMode, int64_t externalMemoryAllocated = 0); |
79 mutable sk_sp<SkShader> m_cachedShader; | 79 mutable sk_sp<SkShader> m_cachedShader; |
80 | 80 |
81 private: | 81 private: |
82 int64_t m_externalMemoryAllocated; | 82 int64_t m_externalMemoryAllocated; |
83 }; | 83 }; |
84 | 84 |
85 } // namespace blink | 85 } // namespace blink |
86 | 86 |
87 #endif | 87 #endif |
OLD | NEW |