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

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

Issue 2007553002: Retire setGradientSpaceTransform, setPatternSpaceTransform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 7 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 , m_externalMemoryAllocated(0) 53 , m_externalMemoryAllocated(0)
54 { 54 {
55 adjustExternalMemoryAllocated(externalMemoryAllocated); 55 adjustExternalMemoryAllocated(externalMemoryAllocated);
56 } 56 }
57 57
58 Pattern::~Pattern() 58 Pattern::~Pattern()
59 { 59 {
60 adjustExternalMemoryAllocated(-m_externalMemoryAllocated); 60 adjustExternalMemoryAllocated(-m_externalMemoryAllocated);
61 } 61 }
62 62
63 void Pattern::applyToPaint(SkPaint& paint) 63 namespace {
64
65 inline bool cachedShaderIsValid(const sk_sp<SkShader>& shader, const SkMatrix* m atrix)
64 { 66 {
65 if (!m_pattern) 67 if (!shader)
66 m_pattern = createShader(); 68 return false;
67 69
68 paint.setShader(m_pattern); 70 const SkMatrix& shaderLocalMatrix = shader->getLocalMatrix();
71 if (!matrix)
72 return shaderLocalMatrix.isIdentity();
73
74 return shaderLocalMatrix == *matrix;
69 } 75 }
70 76
71 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf ormation) 77 } // anonymous namespace
78
79 void Pattern::applyToPaint(SkPaint& paint, const SkMatrix* localMatrix) const
72 { 80 {
73 if (patternSpaceTransformation == m_patternSpaceTransformation) 81 if (!cachedShaderIsValid(m_cachedShader, localMatrix))
74 return; 82 m_cachedShader = createShader(localMatrix);
75 83
76 m_patternSpaceTransformation = patternSpaceTransformation; 84 paint.setShader(m_cachedShader);
77 m_pattern.reset();
78 } 85 }
79 86
80 void Pattern::adjustExternalMemoryAllocated(int64_t delta) 87 void Pattern::adjustExternalMemoryAllocated(int64_t delta)
81 { 88 {
82 delta = std::max(-m_externalMemoryAllocated, delta); 89 delta = std::max(-m_externalMemoryAllocated, delta);
83 90
84 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta); 91 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta);
85 92
86 m_externalMemoryAllocated += delta; 93 m_externalMemoryAllocated += delta;
87 } 94 }
88 95
89 } // namespace blink 96 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698