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/mru_cache.h" | 13 #include "chrome/common/mru_cache.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 #include <windows.h> | 16 #include <windows.h> |
17 #elif defined(OS_MACOSX) | 17 #elif defined(OS_MACOSX) |
18 #include "skia/ext/platform_canvas.h" | 18 #include "skia/ext/platform_canvas.h" |
19 #elif defined(OS_LINUX) | 19 #elif defined(OS_LINUX) |
20 #include "chrome/common/x11_util.h" | 20 #include "chrome/common/x11_util.h" |
21 #endif | 21 #endif |
22 | 22 |
23 class RenderWidgetHost; | 23 class RenderWidgetHost; |
| 24 class SkBitmap; |
24 class TransportDIB; | 25 class TransportDIB; |
25 | 26 |
26 // BackingStore ---------------------------------------------------------------- | 27 // BackingStore ---------------------------------------------------------------- |
27 | 28 |
28 // Represents a backing store for the pixels in a RenderWidgetHost. | 29 // Represents a backing store for the pixels in a RenderWidgetHost. |
29 class BackingStore { | 30 class BackingStore { |
30 public: | 31 public: |
31 #if defined(OS_WIN) || defined(OS_MACOSX) | 32 #if defined(OS_WIN) || defined(OS_MACOSX) |
32 explicit BackingStore(const gfx::Size& size); | 33 BackingStore(RenderWidgetHost* widget, const gfx::Size& size); |
33 #elif defined(OS_LINUX) | 34 #elif defined(OS_LINUX) |
34 // Create a backing store on the X server. | 35 // Create a backing store on the X server. The visual is an Xlib Visual |
35 // size: the size of the server-side pixmap | 36 // describing the format of the target window and the depth is the color |
36 // x_connection: the display to target | 37 // depth of the X window which will be drawn into. |
37 // depth: the depth of the X window which will be drawn into | 38 BackingStore(RenderWidgetHost* widget, |
38 // visual: An Xlib Visual describing the format of the target window | 39 const gfx::Size& size, |
39 // root_window: The X id of the root window | 40 void* visual, |
40 // use_render: if true, the X server supports Xrender | 41 int depth); |
41 // use_shared_memory: if true, the X server is local | 42 |
42 BackingStore(const gfx::Size& size, Display* x_connection, int depth, | |
43 void* visual, XID root_window, bool use_render, | |
44 bool use_shared_memory); | |
45 // This is for unittesting only. An object constructed using this constructor | 43 // This is for unittesting only. An object constructed using this constructor |
46 // will silently ignore all paints | 44 // will silently ignore all paints |
47 explicit BackingStore(const gfx::Size& size); | 45 BackingStore(RenderWidgetHost* widget, const gfx::Size& size); |
48 #endif | 46 #endif |
49 ~BackingStore(); | 47 ~BackingStore(); |
50 | 48 |
| 49 RenderWidgetHost* render_widget_host() const { return render_widget_host_; } |
51 const gfx::Size& size() { return size_; } | 50 const gfx::Size& size() { return size_; } |
52 | 51 |
53 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
54 HDC hdc() { return hdc_; } | 53 HDC hdc() { return hdc_; } |
| 54 |
55 #elif defined(OS_MACOSX) | 55 #elif defined(OS_MACOSX) |
56 skia::PlatformCanvas* canvas() { return &canvas_; } | 56 skia::PlatformCanvas* canvas() { return &canvas_; } |
| 57 |
57 #elif defined(OS_LINUX) | 58 #elif defined(OS_LINUX) |
58 // Copy from the server-side backing store to the target window | 59 // Copy from the server-side backing store to the target window |
59 // display: the display of the backing store and target window | 60 // display: the display of the backing store and target window |
60 // damage: the area to copy | 61 // damage: the area to copy |
61 // target: the X id of the target window | 62 // target: the X id of the target window |
62 void ShowRect(const gfx::Rect& damage, XID target); | 63 void ShowRect(const gfx::Rect& damage, XID target); |
63 #endif | 64 #endif |
64 | 65 |
65 // Paints the bitmap from the renderer onto the backing store. | 66 // Paints the bitmap from the renderer onto the backing store. |
66 void PaintRect(base::ProcessHandle process, | 67 void PaintRect(base::ProcessHandle process, |
67 TransportDIB* bitmap, | 68 TransportDIB* bitmap, |
68 const gfx::Rect& bitmap_rect); | 69 const gfx::Rect& bitmap_rect); |
69 | 70 |
70 // Scrolls the given rect in the backing store, replacing the given region | 71 // Scrolls the given rect in the backing store, replacing the given region |
71 // identified by |bitmap_rect| by the bitmap in the file identified by the | 72 // identified by |bitmap_rect| by the bitmap in the file identified by the |
72 // given file handle. | 73 // given file handle. |
73 void ScrollRect(base::ProcessHandle process, | 74 void ScrollRect(base::ProcessHandle process, |
74 TransportDIB* bitmap, const gfx::Rect& bitmap_rect, | 75 TransportDIB* bitmap, const gfx::Rect& bitmap_rect, |
75 int dx, int dy, | 76 int dx, int dy, |
76 const gfx::Rect& clip_rect, | 77 const gfx::Rect& clip_rect, |
77 const gfx::Size& view_size); | 78 const gfx::Size& view_size); |
78 | 79 |
79 private: | 80 private: |
| 81 // The owner of this backing store. |
| 82 RenderWidgetHost* render_widget_host_; |
| 83 |
80 // The size of the backing store. | 84 // The size of the backing store. |
81 gfx::Size size_; | 85 gfx::Size size_; |
82 | 86 |
83 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
84 | 88 |
85 // The backing store dc. | 89 // The backing store dc. |
86 HDC hdc_; | 90 HDC hdc_; |
87 // Handle to the backing store dib. | 91 // Handle to the backing store dib. |
88 HANDLE backing_store_dib_; | 92 HANDLE backing_store_dib_; |
89 // Handle to the original bitmap in the dc. | 93 // Handle to the original bitmap in the dc. |
(...skipping 26 matching lines...) Expand all Loading... |
116 // This is the RENDER picture pointing at |pixmap_|. | 120 // This is the RENDER picture pointing at |pixmap_|. |
117 XID picture_; | 121 XID picture_; |
118 // This is a default graphic context, used in XCopyArea | 122 // This is a default graphic context, used in XCopyArea |
119 void* pixmap_gc_; | 123 void* pixmap_gc_; |
120 #endif | 124 #endif |
121 | 125 |
122 DISALLOW_COPY_AND_ASSIGN(BackingStore); | 126 DISALLOW_COPY_AND_ASSIGN(BackingStore); |
123 }; | 127 }; |
124 | 128 |
125 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ | 129 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ |
OLD | NEW |