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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_
10 #include "base/basictypes.h"
11 #include "base/callback_forward.h"
12 #include "base/process.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h"
15 #include "ui/surface/transport_dib.h"
19 class RenderWidgetHost
;
21 // This class manages backing stores in the browsr. Every RenderWidgetHost is
22 // 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
24 // stores are maintained in a cache which can be trimmed as needed.
25 class BackingStoreManager
{
27 // Returns a backing store which matches the desired dimensions.
30 // The desired backing store dimensions.
31 // Returns a pointer to the backing store on success, NULL on failure.
32 static BackingStore
* GetBackingStore(RenderWidgetHost
* host
,
33 const gfx::Size
& desired_size
);
35 // 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 // The desired backing store dimensions, in DIPs.
41 // The bitmap section from the renderer.
43 // The rect to be painted into the backing store, in DIPs.
45 // The device scale factor the backing store is expected to be at.
46 // If the backing store's device scale factor doesn't match, it will need
47 // to scale |bitmap| at paint time. This will only be out of sync with the
48 // backing store scale factor for a few frames, right after device scale
51 // Set if we need to send out a request to paint the view
53 static void PrepareBackingStore(
54 RenderWidgetHost
* host
,
55 const gfx::Size
& backing_store_size
,
56 TransportDIB::Id bitmap
,
57 const gfx::Rect
& bitmap_rect
,
58 const std::vector
<gfx::Rect
>& copy_rects
,
60 const base::Closure
& completion_callback
,
61 bool* needs_full_paint
,
62 bool* scheduled_completion_callback
);
64 // Returns a matching backing store for the host.
65 // Returns NULL if we fail to find one.
66 static BackingStore
* Lookup(RenderWidgetHost
* host
);
68 // Removes the backing store for the host.
69 static void RemoveBackingStore(RenderWidgetHost
* host
);
71 // Removes all backing stores.
72 static void RemoveAllBackingStores();
74 // Current size in bytes of the backing store cache.
75 static size_t MemorySize();
78 // Not intended for instantiation.
79 BackingStoreManager() {}
81 DISALLOW_COPY_AND_ASSIGN(BackingStoreManager
);
84 } // namespace content
86 #endif // CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_MANAGER_H_