Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: Source/platform/graphics/Pattern.cpp

Issue 453653003: [SVG] DisplayList-based patterns. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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) 2013 Google, Inc. All rights reserved. 4 * Copyright (C) 2013 Google, Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 11 matching lines...) Expand all
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "platform/graphics/Pattern.h" 29 #include "platform/graphics/Pattern.h"
30 30
31 #include "platform/graphics/BitmapPattern.h" 31 #include "platform/graphics/BitmapPattern.h"
32 #include "platform/graphics/DisplayList.h"
33 #include "platform/graphics/DisplayListPattern.h"
32 #include "platform/graphics/StaticBitmapPattern.h" 34 #include "platform/graphics/StaticBitmapPattern.h"
33 #include "third_party/skia/include/core/SkImage.h" 35 #include "third_party/skia/include/core/SkImage.h"
34 #include "third_party/skia/include/core/SkShader.h" 36 #include "third_party/skia/include/core/SkShader.h"
35 #include <v8.h> 37 #include <v8.h>
36 38
37 namespace blink { 39 namespace blink {
38 40
39 PassRefPtr<Pattern> Pattern::createBitmapPattern(PassRefPtr<Image> tileImage, Re peatMode repeatMode) 41 PassRefPtr<Pattern> Pattern::createBitmapPattern(PassRefPtr<Image> tileImage, Re peatMode repeatMode)
40 { 42 {
41 if (tileImage->skImage()) 43 if (tileImage->skImage())
42 return StaticBitmapPattern::create(tileImage, repeatMode); 44 return StaticBitmapPattern::create(tileImage, repeatMode);
43 45
44 return BitmapPattern::create(tileImage, repeatMode); 46 return BitmapPattern::create(tileImage, repeatMode);
45 } 47 }
46 48
49 PassRefPtr<Pattern> Pattern::createDisplayListPattern(PassRefPtr<DisplayList> di splayList,
50 RepeatMode repeatMode)
51 {
52 return DisplayListPattern::create(displayList, repeatMode);
53 }
54
47 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated) 55 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated)
48 : m_repeatMode(repeatMode) 56 : m_repeatMode(repeatMode)
49 , m_externalMemoryAllocated(0) 57 , m_externalMemoryAllocated(0)
50 { 58 {
51 adjustExternalMemoryAllocated(externalMemoryAllocated); 59 adjustExternalMemoryAllocated(externalMemoryAllocated);
52 } 60 }
53 61
54 Pattern::~Pattern() 62 Pattern::~Pattern()
55 { 63 {
56 adjustExternalMemoryAllocated(-m_externalMemoryAllocated); 64 adjustExternalMemoryAllocated(-m_externalMemoryAllocated);
57 } 65 }
58 66
59 SkShader* Pattern::shader() 67 SkShader* Pattern::shader()
60 { 68 {
61 if (!m_pattern) { 69 if (!m_pattern) {
62 m_pattern = createShader(); 70 m_pattern = createShader();
Stephen White 2014/10/22 15:11:26 Tangentially, it looks like the only reason we nee
fs 2014/10/22 15:29:03 I think this should feasible at least for SVG (I d
f(malita) 2014/10/22 16:23:47 Acknowledged.
63 } 71 }
64 72
65 return m_pattern.get(); 73 return m_pattern.get();
66 } 74 }
67 75
68 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf ormation) 76 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf ormation)
69 { 77 {
70 if (patternSpaceTransformation == m_patternSpaceTransformation) 78 if (patternSpaceTransformation == m_patternSpaceTransformation)
71 return; 79 return;
72 80
73 m_patternSpaceTransformation = patternSpaceTransformation; 81 m_patternSpaceTransformation = patternSpaceTransformation;
74 m_pattern.clear(); 82 m_pattern.clear();
75 } 83 }
76 84
77 void Pattern::adjustExternalMemoryAllocated(int64_t delta) 85 void Pattern::adjustExternalMemoryAllocated(int64_t delta)
78 { 86 {
79 delta = std::max(-m_externalMemoryAllocated, delta); 87 delta = std::max(-m_externalMemoryAllocated, delta);
80 88
81 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta); 89 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta);
82 90
83 m_externalMemoryAllocated += delta; 91 m_externalMemoryAllocated += delta;
84 } 92 }
85 93
86 } // namespace blink 94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698