OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/proxy/ppb_image_data_proxy.h" | 5 #include "ppapi/proxy/ppb_image_data_proxy.h" |
6 | 6 |
7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // Go to the next location, wrapping around to get LRU. | 210 // Go to the next location, wrapping around to get LRU. |
211 next_insertion_point_++; | 211 next_insertion_point_++; |
212 if (next_insertion_point_ >= kCacheSize) | 212 if (next_insertion_point_ >= kCacheSize) |
213 next_insertion_point_ = 0; | 213 next_insertion_point_ = 0; |
214 } | 214 } |
215 | 215 |
216 // ImageDataCache -------------------------------------------------------------- | 216 // ImageDataCache -------------------------------------------------------------- |
217 | 217 |
218 class ImageDataCache { | 218 class ImageDataCache { |
219 public: | 219 public: |
220 ImageDataCache() : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {} | 220 ImageDataCache() : weak_factory_(this) {} |
221 ~ImageDataCache() {} | 221 ~ImageDataCache() {} |
222 | 222 |
223 static ImageDataCache* GetInstance(); | 223 static ImageDataCache* GetInstance(); |
224 | 224 |
225 // Retrieves an image data from the cache of the specified size and format if | 225 // Retrieves an image data from the cache of the specified size and format if |
226 // one exists. If one doesn't exist, this will return a null refptr. | 226 // one exists. If one doesn't exist, this will return a null refptr. |
227 scoped_refptr<ImageData> Get(PP_Instance instance, | 227 scoped_refptr<ImageData> Get(PP_Instance instance, |
228 int width, int height, | 228 int width, int height, |
229 PP_ImageDataFormat format); | 229 PP_ImageDataFormat format); |
230 | 230 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // still cached in our process, the proxy still holds a reference so we can | 628 // still cached in our process, the proxy still holds a reference so we can |
629 // remove the one the renderer just sent is. If the proxy no longer holds a | 629 // remove the one the renderer just sent is. If the proxy no longer holds a |
630 // reference, we released everything and we should also release the one the | 630 // reference, we released everything and we should also release the one the |
631 // renderer just sent us. | 631 // renderer just sent us. |
632 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 632 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
633 API_ID_PPB_CORE, old_image_data)); | 633 API_ID_PPB_CORE, old_image_data)); |
634 } | 634 } |
635 | 635 |
636 } // namespace proxy | 636 } // namespace proxy |
637 } // namespace ppapi | 637 } // namespace ppapi |
OLD | NEW |