| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 // TODO(jam): remove this file when all files have been converted. |
| 10 | 10 #include "content/browser/renderer_host/backing_store_manager.h" |
| 11 #include "app/surface/transport_dib.h" | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/process.h" | |
| 14 #include "ui/gfx/rect.h" | |
| 15 #include "ui/gfx/size.h" | |
| 16 | |
| 17 class BackingStore; | |
| 18 class RenderWidgetHost; | |
| 19 | |
| 20 // This class manages backing stores in the browsr. Every RenderWidgetHost is | |
| 21 // associated with a backing store which it requests from this class. The | |
| 22 // hosts don't maintain any references to the backing stores. These backing | |
| 23 // stores are maintained in a cache which can be trimmed as needed. | |
| 24 class BackingStoreManager { | |
| 25 public: | |
| 26 // Returns a backing store which matches the desired dimensions. | |
| 27 // | |
| 28 // backing_store_rect | |
| 29 // The desired backing store dimensions. | |
| 30 // Returns a pointer to the backing store on success, NULL on failure. | |
| 31 static BackingStore* GetBackingStore(RenderWidgetHost* host, | |
| 32 const gfx::Size& desired_size); | |
| 33 | |
| 34 // Makes a backing store which is fully ready for consumption, i.e. the | |
| 35 // bitmap from the renderer has been copied into the backing store. | |
| 36 // | |
| 37 // backing_store_size | |
| 38 // The desired backing store dimensions. | |
| 39 // bitmap_section | |
| 40 // The bitmap section from the renderer. | |
| 41 // bitmap_rect | |
| 42 // The rect to be painted into the backing store | |
| 43 // needs_full_paint | |
| 44 // Set if we need to send out a request to paint the view | |
| 45 // to the renderer. | |
| 46 static void PrepareBackingStore( | |
| 47 RenderWidgetHost* host, | |
| 48 const gfx::Size& backing_store_size, | |
| 49 TransportDIB::Id bitmap, | |
| 50 const gfx::Rect& bitmap_rect, | |
| 51 const std::vector<gfx::Rect>& copy_rects, | |
| 52 bool* needs_full_paint); | |
| 53 | |
| 54 // Returns a matching backing store for the host. | |
| 55 // Returns NULL if we fail to find one. | |
| 56 static BackingStore* Lookup(RenderWidgetHost* host); | |
| 57 | |
| 58 // Removes the backing store for the host. | |
| 59 static void RemoveBackingStore(RenderWidgetHost* host); | |
| 60 | |
| 61 // Removes all backing stores. | |
| 62 static void RemoveAllBackingStores(); | |
| 63 | |
| 64 // Expires the given backing store. This emulates something getting evicted | |
| 65 // from the cache for the purpose of testing. Returns true if the host was | |
| 66 // removed, false if it wasn't found. | |
| 67 static bool ExpireBackingStoreForTest(RenderWidgetHost* host); | |
| 68 | |
| 69 // Current size in bytes of the backing store cache. | |
| 70 static size_t MemorySize(); | |
| 71 | |
| 72 private: | |
| 73 // Not intended for instantiation. | |
| 74 BackingStoreManager() {} | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(BackingStoreManager); | |
| 77 }; | |
| 78 | 11 |
| 79 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ | 12 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_ |
| OLD | NEW |