| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_X_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_X_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_X_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_X_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 // TODO(jam): remove this file when all files have been converted. |
| 10 #include "build/build_config.h" | 10 #include "content/browser/renderer_host/backing_store_x.h" |
| 11 #include "chrome/browser/renderer_host/backing_store.h" | |
| 12 #include "ui/base/x/x11_util.h" | |
| 13 | |
| 14 namespace gfx { | |
| 15 class Point; | |
| 16 class Rect; | |
| 17 } // namespace gfx | |
| 18 | |
| 19 typedef struct _GdkDrawable GdkDrawable; | |
| 20 class SkBitmap; | |
| 21 | |
| 22 class BackingStoreX : public BackingStore { | |
| 23 public: | |
| 24 // Create a backing store on the X server. The visual is an Xlib Visual | |
| 25 // describing the format of the target window and the depth is the color | |
| 26 // depth of the X window which will be drawn into. | |
| 27 BackingStoreX(RenderWidgetHost* widget, | |
| 28 const gfx::Size& size, | |
| 29 void* visual, | |
| 30 int depth); | |
| 31 | |
| 32 // This is for unittesting only. An object constructed using this constructor | |
| 33 // will silently ignore all paints | |
| 34 BackingStoreX(RenderWidgetHost* widget, const gfx::Size& size); | |
| 35 | |
| 36 virtual ~BackingStoreX(); | |
| 37 | |
| 38 Display* display() const { return display_; } | |
| 39 XID root_window() const { return root_window_; } | |
| 40 | |
| 41 // Copy from the server-side backing store to the target window | |
| 42 // origin: the destination rectangle origin | |
| 43 // damage: the area to copy | |
| 44 // target: the X id of the target window | |
| 45 void XShowRect(const gfx::Point &origin, const gfx::Rect& damage, | |
| 46 XID target); | |
| 47 | |
| 48 // As above, but use Cairo instead of Xlib. | |
| 49 void CairoShowRect(const gfx::Rect& damage, GdkDrawable* drawable); | |
| 50 | |
| 51 #if defined(TOOLKIT_GTK) | |
| 52 // Paint the backing store into the target's |dest_rect|. | |
| 53 void PaintToRect(const gfx::Rect& dest_rect, GdkDrawable* target); | |
| 54 #endif | |
| 55 | |
| 56 // BackingStore implementation. | |
| 57 virtual size_t MemorySize(); | |
| 58 virtual void PaintToBackingStore( | |
| 59 RenderProcessHost* process, | |
| 60 TransportDIB::Id bitmap, | |
| 61 const gfx::Rect& bitmap_rect, | |
| 62 const std::vector<gfx::Rect>& copy_rects); | |
| 63 virtual bool CopyFromBackingStore(const gfx::Rect& rect, | |
| 64 skia::PlatformCanvas* output); | |
| 65 virtual void ScrollBackingStore(int dx, int dy, | |
| 66 const gfx::Rect& clip_rect, | |
| 67 const gfx::Size& view_size); | |
| 68 | |
| 69 private: | |
| 70 // Paints the bitmap from the renderer onto the backing store without | |
| 71 // using Xrender to composite the pixmaps. | |
| 72 void PaintRectWithoutXrender(TransportDIB* bitmap, | |
| 73 const gfx::Rect& bitmap_rect, | |
| 74 const std::vector<gfx::Rect>& copy_rects); | |
| 75 | |
| 76 // This is the connection to the X server where this backing store will be | |
| 77 // displayed. | |
| 78 Display* const display_; | |
| 79 // What flavor, if any, MIT-SHM (X shared memory) support we have. | |
| 80 const ui::SharedMemorySupport shared_memory_support_; | |
| 81 // If this is true, then we can use Xrender to composite our pixmaps. | |
| 82 const bool use_render_; | |
| 83 // If |use_render_| is false, this is the number of bits-per-pixel for |depth| | |
| 84 int pixmap_bpp_; | |
| 85 // if |use_render_| is false, we need the Visual to get the RGB masks. | |
| 86 void* const visual_; | |
| 87 // This is the depth of the target window. | |
| 88 const int visual_depth_; | |
| 89 // The parent window (probably a GtkDrawingArea) for this backing store. | |
| 90 const XID root_window_; | |
| 91 // This is a handle to the server side pixmap which is our backing store. | |
| 92 XID pixmap_; | |
| 93 // This is the RENDER picture pointing at |pixmap_|. | |
| 94 XID picture_; | |
| 95 // This is a default graphic context, used in XCopyArea | |
| 96 void* pixmap_gc_; | |
| 97 | |
| 98 DISALLOW_COPY_AND_ASSIGN(BackingStoreX); | |
| 99 }; | |
| 100 | 11 |
| 101 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_X_H_ | 12 #endif // CHROME_BROWSER_RENDERER_HOST_BACKING_STORE_X_H_ |
| OLD | NEW |