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 "base/scoped_cftyperef.h" | 18 #include "base/scoped_cftyperef.h" |
19 #include "skia/ext/platform_canvas.h" | 19 #include "skia/ext/platform_canvas.h" |
20 #elif defined(OS_LINUX) | 20 #elif defined(USE_X11) |
21 #include "chrome/common/x11_util.h" | 21 #include "chrome/common/x11_util.h" |
22 #endif | 22 #endif |
23 | 23 |
24 class RenderWidgetHost; | 24 class RenderWidgetHost; |
25 class SkBitmap; | 25 class SkBitmap; |
26 class TransportDIB; | 26 class TransportDIB; |
27 typedef struct _GdkDrawable GdkDrawable; | 27 typedef struct _GdkDrawable GdkDrawable; |
28 | 28 |
29 // BackingStore ---------------------------------------------------------------- | 29 // BackingStore ---------------------------------------------------------------- |
30 | 30 |
31 // Represents a backing store for the pixels in a RenderWidgetHost. | 31 // Represents a backing store for the pixels in a RenderWidgetHost. |
32 class BackingStore { | 32 class BackingStore { |
33 public: | 33 public: |
34 #if defined(OS_WIN) || defined(OS_MACOSX) | 34 #if defined(OS_WIN) || defined(OS_MACOSX) |
35 BackingStore(RenderWidgetHost* widget, const gfx::Size& size); | 35 BackingStore(RenderWidgetHost* widget, const gfx::Size& size); |
36 #elif defined(OS_LINUX) | 36 #elif defined(USE_X11) |
37 // Create a backing store on the X server. The visual is an Xlib Visual | 37 // Create a backing store on the X server. The visual is an Xlib Visual |
38 // describing the format of the target window and the depth is the color | 38 // describing the format of the target window and the depth is the color |
39 // depth of the X window which will be drawn into. | 39 // depth of the X window which will be drawn into. |
40 BackingStore(RenderWidgetHost* widget, | 40 BackingStore(RenderWidgetHost* widget, |
41 const gfx::Size& size, | 41 const gfx::Size& size, |
42 void* visual, | 42 void* visual, |
43 int depth); | 43 int depth); |
44 | 44 |
45 // This is for unittesting only. An object constructed using this constructor | 45 // This is for unittesting only. An object constructed using this constructor |
46 // will silently ignore all paints | 46 // will silently ignore all paints |
(...skipping 17 matching lines...) Expand all Loading... |
64 // A CGLayer that stores the contents of the backing store, cached in GPU | 64 // A CGLayer that stores the contents of the backing store, cached in GPU |
65 // memory if possible. | 65 // memory if possible. |
66 CGLayerRef cg_layer() { return cg_layer_; } | 66 CGLayerRef cg_layer() { return cg_layer_; } |
67 // A CGBitmapContext that stores the contents of the backing store if the | 67 // A CGBitmapContext that stores the contents of the backing store if the |
68 // corresponding Cocoa view has not been inserted into an NSWindow yet. | 68 // corresponding Cocoa view has not been inserted into an NSWindow yet. |
69 CGContextRef cg_bitmap() { return cg_bitmap_; } | 69 CGContextRef cg_bitmap() { return cg_bitmap_; } |
70 | 70 |
71 // Paint the layer into a graphics context--if the target is a window, | 71 // Paint the layer into a graphics context--if the target is a window, |
72 // this should be a GPU->GPU copy (and therefore very fast). | 72 // this should be a GPU->GPU copy (and therefore very fast). |
73 void PaintToRect(const gfx::Rect& dest_rect, CGContextRef target); | 73 void PaintToRect(const gfx::Rect& dest_rect, CGContextRef target); |
74 #elif defined(OS_LINUX) | 74 #elif defined(USE_X11) |
75 Display* display() const { return display_; } | 75 Display* display() const { return display_; } |
76 XID root_window() const { return root_window_; }; | 76 XID root_window() const { return root_window_; }; |
77 | 77 |
78 // Copy from the server-side backing store to the target window | 78 // Copy from the server-side backing store to the target window |
79 // display: the display of the backing store and target window | 79 // display: the display of the backing store and target window |
80 // damage: the area to copy | 80 // damage: the area to copy |
81 // target: the X id of the target window | 81 // target: the X id of the target window |
82 void ShowRect(const gfx::Rect& damage, XID target); | 82 void ShowRect(const gfx::Rect& damage, XID target); |
83 | 83 |
84 // Paints the server-side backing store data to a SkBitmap. On failure, the | 84 // Paints the server-side backing store data to a SkBitmap. On failure, the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 HDC hdc_; | 117 HDC hdc_; |
118 // Handle to the backing store dib. | 118 // Handle to the backing store dib. |
119 HANDLE backing_store_dib_; | 119 HANDLE backing_store_dib_; |
120 // Handle to the original bitmap in the dc. | 120 // Handle to the original bitmap in the dc. |
121 HANDLE original_bitmap_; | 121 HANDLE original_bitmap_; |
122 // Number of bits per pixel of the screen. | 122 // Number of bits per pixel of the screen. |
123 int color_depth_; | 123 int color_depth_; |
124 #elif defined(OS_MACOSX) | 124 #elif defined(OS_MACOSX) |
125 scoped_cftyperef<CGContextRef> cg_bitmap_; | 125 scoped_cftyperef<CGContextRef> cg_bitmap_; |
126 scoped_cftyperef<CGLayerRef> cg_layer_; | 126 scoped_cftyperef<CGLayerRef> cg_layer_; |
127 #elif defined(OS_LINUX) | 127 #elif defined(USE_X11) |
128 // Paints the bitmap from the renderer onto the backing store without | 128 // Paints the bitmap from the renderer onto the backing store without |
129 // using Xrender to composite the pixmaps. | 129 // using Xrender to composite the pixmaps. |
130 void PaintRectWithoutXrender(TransportDIB* bitmap, | 130 void PaintRectWithoutXrender(TransportDIB* bitmap, |
131 const gfx::Rect& bitmap_rect); | 131 const gfx::Rect& bitmap_rect); |
132 | 132 |
133 // This is the connection to the X server where this backing store will be | 133 // This is the connection to the X server where this backing store will be |
134 // displayed. | 134 // displayed. |
135 Display* const display_; | 135 Display* const display_; |
136 // If this is true, then |connection_| is good for MIT-SHM (X shared memory). | 136 // If this is true, then |connection_| is good for MIT-SHM (X shared memory). |
137 const bool use_shared_memory_; | 137 const bool use_shared_memory_; |
(...skipping 12 matching lines...) Expand all Loading... |
150 // This is the RENDER picture pointing at |pixmap_|. | 150 // This is the RENDER picture pointing at |pixmap_|. |
151 XID picture_; | 151 XID picture_; |
152 // This is a default graphic context, used in XCopyArea | 152 // This is a default graphic context, used in XCopyArea |
153 void* pixmap_gc_; | 153 void* pixmap_gc_; |
154 #endif | 154 #endif |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(BackingStore); | 156 DISALLOW_COPY_AND_ASSIGN(BackingStore); |
157 }; | 157 }; |
158 | 158 |
159 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ | 159 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_H_ |
OLD | NEW |