OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
10 #include "base/gfx/size.h" | 10 #include "base/gfx/size.h" |
11 #include "base/process.h" | 11 #include "base/process.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/common/bitmap_wire_data.h" |
13 #include "chrome/common/mru_cache.h" | 14 #include "chrome/common/mru_cache.h" |
14 | 15 |
15 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
16 #include <windows.h> | 17 #include <windows.h> |
| 18 #elif defined(OS_POSIX) |
| 19 #include "skia/ext/platform_canvas.h" |
17 #endif | 20 #endif |
18 | 21 |
19 class RenderWidgetHost; | 22 class RenderWidgetHost; |
20 | 23 |
21 // BackingStore ---------------------------------------------------------------- | 24 // BackingStore ---------------------------------------------------------------- |
22 | 25 |
23 // Represents a backing store for the pixels in a RenderWidgetHost. | 26 // Represents a backing store for the pixels in a RenderWidgetHost. |
24 class BackingStore { | 27 class BackingStore { |
25 public: | 28 public: |
26 explicit BackingStore(const gfx::Size& size); | 29 explicit BackingStore(const gfx::Size& size); |
27 ~BackingStore(); | 30 ~BackingStore(); |
28 | 31 |
29 const gfx::Size& size() { return size_; } | 32 const gfx::Size& size() { return size_; } |
30 | 33 |
31 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
32 HDC hdc() { return hdc_; } | 35 HDC hdc() { return hdc_; } |
33 #endif | 36 #endif |
34 | 37 |
35 // Paints the bitmap from the renderer onto the backing store. | 38 // Paints the bitmap from the renderer onto the backing store. |
36 // TODO(port): The HANDLE is a shared section on Windows. Abstract this. | |
37 bool PaintRect(base::ProcessHandle process, | 39 bool PaintRect(base::ProcessHandle process, |
38 HANDLE bitmap_section, | 40 BitmapWireData bitmap_section, |
39 const gfx::Rect& bitmap_rect); | 41 const gfx::Rect& bitmap_rect); |
40 | 42 |
41 // Scrolls the given rect in the backing store, replacing the given region | 43 // Scrolls the given rect in the backing store, replacing the given region |
42 // identified by |bitmap_rect| by the bitmap in the file identified by the | 44 // identified by |bitmap_rect| by the bitmap in the file identified by the |
43 // given file handle. | 45 // given file handle. |
44 // TODO(port): The HANDLE is a shared section on Windows. Abstract this. | |
45 void ScrollRect(base::ProcessHandle process, | 46 void ScrollRect(base::ProcessHandle process, |
46 HANDLE bitmap, const gfx::Rect& bitmap_rect, | 47 BitmapWireData bitmap, const gfx::Rect& bitmap_rect, |
47 int dx, int dy, | 48 int dx, int dy, |
48 const gfx::Rect& clip_rect, | 49 const gfx::Rect& clip_rect, |
49 const gfx::Size& view_size); | 50 const gfx::Size& view_size); |
50 | 51 |
51 private: | 52 private: |
52 // The size of the backing store. | 53 // The size of the backing store. |
53 gfx::Size size_; | 54 gfx::Size size_; |
54 | 55 |
55 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
56 // Creates a dib conforming to the height/width/section parameters passed | 57 // Creates a dib conforming to the height/width/section parameters passed |
57 // in. The use_os_color_depth parameter controls whether we use the color | 58 // in. The use_os_color_depth parameter controls whether we use the color |
58 // depth to create an appropriate dib or not. | 59 // depth to create an appropriate dib or not. |
59 HANDLE CreateDIB(HDC dc, | 60 HANDLE CreateDIB(HDC dc, |
60 int width, int height, | 61 int width, int height, |
61 bool use_os_color_depth, | 62 bool use_os_color_depth, |
62 HANDLE section); | 63 HANDLE section); |
63 | 64 |
64 // The backing store dc. | 65 // The backing store dc. |
65 HDC hdc_; | 66 HDC hdc_; |
66 | 67 |
67 // Handle to the backing store dib. | 68 // Handle to the backing store dib. |
68 HANDLE backing_store_dib_; | 69 HANDLE backing_store_dib_; |
69 | 70 |
70 // Handle to the original bitmap in the dc. | 71 // Handle to the original bitmap in the dc. |
71 HANDLE original_bitmap_; | 72 HANDLE original_bitmap_; |
72 #endif | 73 #elif defined(OS_POSIX) |
| 74 skia::PlatformCanvas canvas_; |
| 75 #endif // defined(OS_WIN) |
73 | 76 |
74 DISALLOW_COPY_AND_ASSIGN(BackingStore); | 77 DISALLOW_COPY_AND_ASSIGN(BackingStore); |
75 }; | 78 }; |
76 | 79 |
77 // BackingStoreManager --------------------------------------------------------- | 80 // BackingStoreManager --------------------------------------------------------- |
78 | 81 |
79 // This class manages backing stores in the browsr. Every RenderWidgetHost is | 82 // This class manages backing stores in the browsr. Every RenderWidgetHost is |
80 // associated with a backing store which it requests from this class. The | 83 // associated with a backing store which it requests from this class. The |
81 // hosts don't maintain any references to the backing stores. These backing | 84 // hosts don't maintain any references to the backing stores. These backing |
82 // stores are maintained in a cache which can be trimmed as needed. | 85 // stores are maintained in a cache which can be trimmed as needed. |
(...skipping 15 matching lines...) Expand all Loading... |
98 // The desired backing store dimensions. | 101 // The desired backing store dimensions. |
99 // process_handle | 102 // process_handle |
100 // The renderer process handle. | 103 // The renderer process handle. |
101 // bitmap_section | 104 // bitmap_section |
102 // The bitmap section from the renderer. | 105 // The bitmap section from the renderer. |
103 // bitmap_rect | 106 // bitmap_rect |
104 // The rect to be painted into the backing store | 107 // The rect to be painted into the backing store |
105 // needs_full_paint | 108 // needs_full_paint |
106 // Set if we need to send out a request to paint the view | 109 // Set if we need to send out a request to paint the view |
107 // to the renderer. | 110 // to the renderer. |
108 // TODO(port): The HANDLE is a shared section on Windows. Abstract this. | |
109 static BackingStore* PrepareBackingStore(RenderWidgetHost* host, | 111 static BackingStore* PrepareBackingStore(RenderWidgetHost* host, |
110 const gfx::Rect& backing_store_rect, | 112 const gfx::Rect& backing_store_rect, |
111 base::ProcessHandle process_handle, | 113 base::ProcessHandle process_handle, |
112 HANDLE bitmap_section, | 114 BitmapWireData bitmap_section, |
113 const gfx::Rect& bitmap_rect, | 115 const gfx::Rect& bitmap_rect, |
114 bool* needs_full_paint); | 116 bool* needs_full_paint); |
115 | 117 |
116 // Returns a matching backing store for the host. | 118 // Returns a matching backing store for the host. |
117 // Returns NULL if we fail to find one. | 119 // Returns NULL if we fail to find one. |
118 static BackingStore* Lookup(RenderWidgetHost* host); | 120 static BackingStore* Lookup(RenderWidgetHost* host); |
119 | 121 |
120 // Removes the backing store for the host. | 122 // Removes the backing store for the host. |
121 static void RemoveBackingStore(RenderWidgetHost* host); | 123 static void RemoveBackingStore(RenderWidgetHost* host); |
122 | 124 |
123 private: | 125 private: |
124 // Not intended for instantiation. | 126 // Not intended for instantiation. |
125 BackingStoreManager() {} | 127 BackingStoreManager() {} |
126 | 128 |
127 DISALLOW_COPY_AND_ASSIGN(BackingStoreManager); | 129 DISALLOW_COPY_AND_ASSIGN(BackingStoreManager); |
128 }; | 130 }; |
129 | 131 |
130 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ | 132 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ |
OLD | NEW |