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

Side by Side Diff: Source/WebCore/platform/graphics/skia/PatternSkia.cpp

Issue 9599019: Merge 109171 - [chromium] Inform v8 about extra memory used for PatternSkia clamp mode (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 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
« no previous file with comments | « Source/WebCore/platform/graphics/Pattern.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Google Inc. All rights reserved. 2 * Copyright (C) 2008 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 20 matching lines...) Expand all
31 31
32 #include "AffineTransform.h" 32 #include "AffineTransform.h"
33 #include "Image.h" 33 #include "Image.h"
34 #include "NativeImageSkia.h" 34 #include "NativeImageSkia.h"
35 35
36 #include "SkCanvas.h" 36 #include "SkCanvas.h"
37 #include "SkColor.h" 37 #include "SkColor.h"
38 #include "SkColorShader.h" 38 #include "SkColorShader.h"
39 #include "SkShader.h" 39 #include "SkShader.h"
40 40
41 #include <v8.h>
42
41 namespace WebCore { 43 namespace WebCore {
42 44
43 void Pattern::platformDestroy() 45 void Pattern::platformDestroy()
44 { 46 {
45 SkSafeUnref(m_pattern); 47 SkSafeUnref(m_pattern);
46 m_pattern = 0; 48 m_pattern = 0;
49 if (m_externalMemoryAllocated) {
50 v8::V8::AdjustAmountOfExternalAllocatedMemory(-m_externalMemoryAllocated );
51 m_externalMemoryAllocated = 0;
52 }
47 } 53 }
48 54
49 PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransf orm) 55 PlatformPatternPtr Pattern::platformPattern(const AffineTransform& patternTransf orm)
50 { 56 {
51 if (m_pattern) 57 if (m_pattern)
52 return m_pattern; 58 return m_pattern;
53 59
54 // Note: patternTransform is ignored since it seems to be applied elsewhere 60 // Note: patternTransform is ignored since it seems to be applied elsewhere
55 // (when the pattern is used?). Applying it to the pattern (i.e. 61 // (when the pattern is used?). Applying it to the pattern (i.e.
56 // shader->setLocalMatrix) results in a double transformation. This can be 62 // shader->setLocalMatrix) results in a double transformation. This can be
(...skipping 25 matching lines...) Expand all
82 // Create a transparent bitmap 1 pixel wider and/or taller than the 88 // Create a transparent bitmap 1 pixel wider and/or taller than the
83 // original, then copy the orignal into it. 89 // original, then copy the orignal into it.
84 // FIXME: Is there a better way to pad (not scale) an image in skia? 90 // FIXME: Is there a better way to pad (not scale) an image in skia?
85 SkBitmap bm2; 91 SkBitmap bm2;
86 bm2.setConfig(image->bitmap().config(), image->bitmap().width() + expand W, image->bitmap().height() + expandH); 92 bm2.setConfig(image->bitmap().config(), image->bitmap().width() + expand W, image->bitmap().height() + expandH);
87 bm2.allocPixels(); 93 bm2.allocPixels();
88 bm2.eraseARGB(0x00, 0x00, 0x00, 0x00); 94 bm2.eraseARGB(0x00, 0x00, 0x00, 0x00);
89 SkCanvas canvas(bm2); 95 SkCanvas canvas(bm2);
90 canvas.drawBitmap(image->bitmap(), 0, 0); 96 canvas.drawBitmap(image->bitmap(), 0, 0);
91 m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY); 97 m_pattern = SkShader::CreateBitmapShader(bm2, tileModeX, tileModeY);
98
99 m_externalMemoryAllocated = bm2.getSafeSize();
100 v8::V8::AdjustAmountOfExternalAllocatedMemory(m_externalMemoryAllocated) ;
92 } 101 }
93 m_pattern->setLocalMatrix(m_patternSpaceTransformation); 102 m_pattern->setLocalMatrix(m_patternSpaceTransformation);
94 return m_pattern; 103 return m_pattern;
95 } 104 }
96 105
97 void Pattern::setPlatformPatternSpaceTransform() 106 void Pattern::setPlatformPatternSpaceTransform()
98 { 107 {
99 if (m_pattern) 108 if (m_pattern)
100 m_pattern->setLocalMatrix(m_patternSpaceTransformation); 109 m_pattern->setLocalMatrix(m_patternSpaceTransformation);
101 } 110 }
102 111
103 } // namespace WebCore 112 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/platform/graphics/Pattern.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698