| 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) 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 29 matching lines...) Expand all Loading... |
| 40 { | 40 { |
| 41 return ImagePattern::create(tileImage, repeatMode); | 41 return ImagePattern::create(tileImage, repeatMode); |
| 42 } | 42 } |
| 43 | 43 |
| 44 PassRefPtr<Pattern> Pattern::createPicturePattern(PassRefPtr<const SkPicture> pi
cture, | 44 PassRefPtr<Pattern> Pattern::createPicturePattern(PassRefPtr<const SkPicture> pi
cture, |
| 45 RepeatMode repeatMode) | 45 RepeatMode repeatMode) |
| 46 { | 46 { |
| 47 return PicturePattern::create(picture, repeatMode); | 47 return PicturePattern::create(picture, repeatMode); |
| 48 } | 48 } |
| 49 | 49 |
| 50 Pattern::Pattern(RepeatMode repeatMode, int64_t externalMemoryAllocated) | 50 Pattern::Pattern(RepeatMode repeatMode) |
| 51 : m_repeatMode(repeatMode) | 51 : m_repeatMode(repeatMode) |
| 52 , m_externalMemoryAllocated(0) | |
| 53 { | 52 { |
| 54 adjustExternalMemoryAllocated(externalMemoryAllocated); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 Pattern::~Pattern() | 55 Pattern::~Pattern() |
| 58 { | 56 { |
| 59 adjustExternalMemoryAllocated(-m_externalMemoryAllocated); | |
| 60 } | 57 } |
| 61 | 58 |
| 62 void Pattern::applyToPaint(SkPaint& paint) | 59 void Pattern::applyToPaint(SkPaint& paint) |
| 63 { | 60 { |
| 64 if (!m_pattern) { | 61 if (!m_pattern) { |
| 65 m_pattern = createShader(); | 62 m_pattern = createShader(); |
| 66 } | 63 } |
| 67 | 64 |
| 68 paint.setShader(m_pattern.get()); | 65 paint.setShader(m_pattern.get()); |
| 69 } | 66 } |
| 70 | 67 |
| 71 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf
ormation) | 68 void Pattern::setPatternSpaceTransform(const AffineTransform& patternSpaceTransf
ormation) |
| 72 { | 69 { |
| 73 if (patternSpaceTransformation == m_patternSpaceTransformation) | 70 if (patternSpaceTransformation == m_patternSpaceTransformation) |
| 74 return; | 71 return; |
| 75 | 72 |
| 76 m_patternSpaceTransformation = patternSpaceTransformation; | 73 m_patternSpaceTransformation = patternSpaceTransformation; |
| 77 m_pattern.clear(); | 74 m_pattern.clear(); |
| 78 } | 75 } |
| 79 | 76 |
| 80 void Pattern::adjustExternalMemoryAllocated(int64_t delta) | |
| 81 { | |
| 82 delta = std::max(-m_externalMemoryAllocated, delta); | |
| 83 | |
| 84 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(delta); | |
| 85 | |
| 86 m_externalMemoryAllocated += delta; | |
| 87 } | |
| 88 | |
| 89 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |