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