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

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

Issue 1814473003: Revert of Add sk_sp helpers and switch Blink SkShader clients to the new APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 "platform/graphics/Pattern.h" 28 #include "platform/graphics/Pattern.h"
29 29
30 #include "platform/graphics/ImagePattern.h" 30 #include "platform/graphics/ImagePattern.h"
31 #include "platform/graphics/PicturePattern.h" 31 #include "platform/graphics/PicturePattern.h"
32 #include "platform/graphics/skia/SkiaUtils.h"
33 #include "third_party/skia/include/core/SkImage.h" 32 #include "third_party/skia/include/core/SkImage.h"
34 #include "third_party/skia/include/core/SkPicture.h" 33 #include "third_party/skia/include/core/SkPicture.h"
35 #include "third_party/skia/include/core/SkShader.h" 34 #include "third_party/skia/include/core/SkShader.h"
36 #include <v8.h> 35 #include <v8.h>
37 36
38 namespace blink { 37 namespace blink {
39 38
40 PassRefPtr<Pattern> Pattern::createImagePattern(PassRefPtr<Image> tileImage, Rep eatMode repeatMode) 39 PassRefPtr<Pattern> Pattern::createImagePattern(PassRefPtr<Image> tileImage, Rep eatMode repeatMode)
41 { 40 {
42 return ImagePattern::create(tileImage, repeatMode); 41 return ImagePattern::create(tileImage, repeatMode);
43 } 42 }
44 43
45 PassRefPtr<Pattern> Pattern::createPicturePattern(PassRefPtr<SkPicture> picture, 44 PassRefPtr<Pattern> Pattern::createPicturePattern(PassRefPtr<const SkPicture> pi cture,
46 RepeatMode repeatMode) 45 RepeatMode repeatMode)
47 { 46 {
48 return PicturePattern::create(picture, repeatMode); 47 return PicturePattern::create(picture, repeatMode);
49 } 48 }
50 49
51 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated) 50 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated)
52 : m_repeatMode(repeatMode) 51 : m_repeatMode(repeatMode)
53 , m_externalMemoryAllocated(0) 52 , m_externalMemoryAllocated(0)
54 { 53 {
55 adjustExternalMemoryAllocated(externalMemoryAllocated); 54 adjustExternalMemoryAllocated(externalMemoryAllocated);
56 } 55 }
57 56
58 Pattern::~Pattern() 57 Pattern::~Pattern()
59 { 58 {
60 adjustExternalMemoryAllocated(-m_externalMemoryAllocated); 59 adjustExternalMemoryAllocated(-m_externalMemoryAllocated);
61 } 60 }
62 61
63 void Pattern::applyToPaint(SkPaint& paint) 62 void Pattern::applyToPaint(SkPaint& paint)
64 { 63 {
65 if (!m_pattern) { 64 if (!m_pattern) {
66 m_pattern = createShader(); 65 m_pattern = createShader();
67 } 66 }
68 67
69 paint.setShader(adoptSkSp<SkShader>(m_pattern)); 68 paint.setShader(m_pattern.get());
70 } 69 }
71 70
72 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf ormation) 71 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf ormation)
73 { 72 {
74 if (patternSpaceTransformation == m_patternSpaceTransformation) 73 if (patternSpaceTransformation == m_patternSpaceTransformation)
75 return; 74 return;
76 75
77 m_patternSpaceTransformation = patternSpaceTransformation; 76 m_patternSpaceTransformation = patternSpaceTransformation;
78 m_pattern.clear(); 77 m_pattern.clear();
79 } 78 }
80 79
81 void Pattern::adjustExternalMemoryAllocated(int64_t delta) 80 void Pattern::adjustExternalMemoryAllocated(int64_t delta)
82 { 81 {
83 delta = std::max(-m_externalMemoryAllocated, delta); 82 delta = std::max(-m_externalMemoryAllocated, delta);
84 83
85 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta); 84 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta);
86 85
87 m_externalMemoryAllocated += delta; 86 m_externalMemoryAllocated += delta;
88 } 87 }
89 88
90 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Pattern.h ('k') | third_party/WebKit/Source/platform/graphics/PicturePattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698