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

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

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Rebase Created 3 years, 10 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/paint/PaintFlags.h"
33 #include "platform/graphics/paint/PaintRecord.h"
32 #include "platform/graphics/skia/SkiaUtils.h" 34 #include "platform/graphics/skia/SkiaUtils.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/SkPicture.h"
35 #include "third_party/skia/include/core/SkShader.h" 36 #include "third_party/skia/include/core/SkShader.h"
36 #include <v8.h> 37 #include <v8.h>
37 38
38 namespace blink { 39 namespace blink {
39 40
40 PassRefPtr<Pattern> Pattern::createImagePattern(PassRefPtr<Image> tileImage, 41 PassRefPtr<Pattern> Pattern::createImagePattern(PassRefPtr<Image> tileImage,
41 RepeatMode repeatMode) { 42 RepeatMode repeatMode) {
42 return ImagePattern::create(std::move(tileImage), repeatMode); 43 return ImagePattern::create(std::move(tileImage), repeatMode);
43 } 44 }
44 45
45 PassRefPtr<Pattern> Pattern::createPicturePattern(sk_sp<SkPicture> picture, 46 PassRefPtr<Pattern> Pattern::createPicturePattern(sk_sp<PaintRecord> picture,
46 RepeatMode repeatMode) { 47 RepeatMode repeatMode) {
47 return PicturePattern::create(std::move(picture), repeatMode); 48 return PicturePattern::create(std::move(picture), repeatMode);
48 } 49 }
49 50
50 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated) 51 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated)
51 : m_repeatMode(repeatMode), m_externalMemoryAllocated(0) { 52 : m_repeatMode(repeatMode), m_externalMemoryAllocated(0) {
52 adjustExternalMemoryAllocated(externalMemoryAllocated); 53 adjustExternalMemoryAllocated(externalMemoryAllocated);
53 } 54 }
54 55
55 Pattern::~Pattern() { 56 Pattern::~Pattern() {
56 adjustExternalMemoryAllocated(-m_externalMemoryAllocated); 57 adjustExternalMemoryAllocated(-m_externalMemoryAllocated);
57 } 58 }
58 59
59 void Pattern::applyToPaint(SkPaint& paint, const SkMatrix& localMatrix) { 60 void Pattern::applyToPaint(PaintFlags& paint, const SkMatrix& localMatrix) {
60 if (!m_cachedShader || isLocalMatrixChanged(localMatrix)) 61 if (!m_cachedShader || isLocalMatrixChanged(localMatrix))
61 m_cachedShader = createShader(localMatrix); 62 m_cachedShader = createShader(localMatrix);
62 63
63 paint.setShader(m_cachedShader); 64 paint.setShader(m_cachedShader);
64 } 65 }
65 66
66 bool Pattern::isLocalMatrixChanged(const SkMatrix& localMatrix) const { 67 bool Pattern::isLocalMatrixChanged(const SkMatrix& localMatrix) const {
67 return localMatrix != m_cachedShader->getLocalMatrix(); 68 return localMatrix != m_cachedShader->getLocalMatrix();
68 } 69 }
69 70
70 void Pattern::adjustExternalMemoryAllocated(int64_t delta) { 71 void Pattern::adjustExternalMemoryAllocated(int64_t delta) {
71 delta = std::max(-m_externalMemoryAllocated, delta); 72 delta = std::max(-m_externalMemoryAllocated, delta);
72 73
73 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta); 74 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta);
74 75
75 m_externalMemoryAllocated += delta; 76 m_externalMemoryAllocated += delta;
76 } 77 }
77 78
78 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698