OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // 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 are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * 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 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 m_resizeRequests = 0; | 54 m_resizeRequests = 0; |
55 } | 55 } |
56 | 56 |
57 return m_resizedImage.width() == w && m_resizedImage.height() == h; | 57 return m_resizedImage.width() == w && m_resizedImage.height() == h; |
58 } | 58 } |
59 | 59 |
60 // FIXME(brettw) don't cache when image is in-progress. | 60 // FIXME(brettw) don't cache when image is in-progress. |
61 | 61 |
62 SkBitmap NativeImageSkia::resizedBitmap(int w, int h) const { | 62 SkBitmap NativeImageSkia::resizedBitmap(int w, int h) const { |
63 if (m_resizedImage.width() != w || m_resizedImage.height() != h) { | 63 if (m_resizedImage.width() != w || m_resizedImage.height() != h) { |
64 m_resizedImage = gfx::ImageOperations::Resize(*this, | 64 m_resizedImage = skia::ImageOperations::Resize(*this, |
65 gfx::ImageOperations::RESIZE_LANCZOS3, gfx::Size(w, h)); | 65 skia::ImageOperations::RESIZE_LANCZOS3, w, h); |
66 } | 66 } |
67 return m_resizedImage; | 67 return m_resizedImage; |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 bool NativeImageSkia::shouldCacheResampling(int dest_width, | 71 bool NativeImageSkia::shouldCacheResampling(int dest_width, |
72 int dest_height, | 72 int dest_height, |
73 int dest_subset_width, | 73 int dest_subset_width, |
74 int dest_subset_height) const { | 74 int dest_subset_height) const { |
75 // We can not cache incomplete frames. This might be a good optimization in | 75 // We can not cache incomplete frames. This might be a good optimization in |
(...skipping 22 matching lines...) Expand all Loading... |
98 m_lastRequestSize = WebCore::IntSize(dest_width, dest_height); | 98 m_lastRequestSize = WebCore::IntSize(dest_width, dest_height); |
99 m_resizeRequests = 0; | 99 m_resizeRequests = 0; |
100 } | 100 } |
101 | 101 |
102 // Otherwise, use the heuristic that if more than 1/4 of the image is | 102 // Otherwise, use the heuristic that if more than 1/4 of the image is |
103 // requested, it's worth caching. | 103 // requested, it's worth caching. |
104 int dest_size = dest_width * dest_height; | 104 int dest_size = dest_width * dest_height; |
105 int dest_subset_size = dest_subset_width * dest_subset_height; | 105 int dest_subset_size = dest_subset_width * dest_subset_height; |
106 return dest_size / 4 < dest_subset_size; | 106 return dest_size / 4 < dest_subset_size; |
107 } | 107 } |
OLD | NEW |