Suppress sending mousedown / mouseup when in fling
[chromium-blink-merge.git] / content / browser / renderer_host / backing_store_gtk.h
blob878c28d70762133be4a0fbfaa11f25a398ac228e
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_GTK_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_GTK_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "build/build_config.h"
13 #include "content/browser/renderer_host/backing_store.h"
14 #include "content/common/content_export.h"
15 #include "ui/base/x/x11_util.h"
17 namespace gfx {
18 class Point;
19 class Rect;
22 typedef struct _GdkDrawable GdkDrawable;
24 namespace content {
26 class CONTENT_EXPORT BackingStoreGtk : public BackingStore {
27 public:
28 // Create a backing store on the X server. The visual is an Xlib Visual
29 // describing the format of the target window and the depth is the color
30 // depth of the X window which will be drawn into.
31 BackingStoreGtk(RenderWidgetHost* widget,
32 const gfx::Size& size,
33 void* visual,
34 int depth);
36 // This is for unittesting only. An object constructed using this constructor
37 // will silently ignore all paints
38 BackingStoreGtk(RenderWidgetHost* widget, const gfx::Size& size);
40 virtual ~BackingStoreGtk();
42 Display* display() const { return display_; }
43 XID root_window() const { return root_window_; }
45 // Copy from the server-side backing store to the target window
46 // origin: the destination rectangle origin
47 // damage: the area to copy
48 // target: the X id of the target window
49 void XShowRect(const gfx::Point &origin, const gfx::Rect& damage,
50 XID target);
52 // As above, but use Cairo instead of Xlib.
53 void CairoShowRect(const gfx::Rect& damage, GdkDrawable* drawable);
55 #if defined(TOOLKIT_GTK)
56 // Paint the backing store into the target's |dest_rect|.
57 void PaintToRect(const gfx::Rect& dest_rect, GdkDrawable* target);
58 #endif
60 // BackingStore implementation.
61 virtual size_t MemorySize() OVERRIDE;
62 virtual void PaintToBackingStore(
63 RenderProcessHost* process,
64 TransportDIB::Id bitmap,
65 const gfx::Rect& bitmap_rect,
66 const std::vector<gfx::Rect>& copy_rects,
67 float scale_factor,
68 const base::Closure& completion_callback,
69 bool* scheduled_completion_callback) OVERRIDE;
70 virtual bool CopyFromBackingStore(const gfx::Rect& rect,
71 skia::PlatformBitmap* output) OVERRIDE;
72 virtual void ScrollBackingStore(const gfx::Vector2d& delta,
73 const gfx::Rect& clip_rect,
74 const gfx::Size& view_size) OVERRIDE;
76 private:
77 // Paints the bitmap from the renderer onto the backing store without
78 // using Xrender to composite the pixmaps.
79 void PaintRectWithoutXrender(TransportDIB* bitmap,
80 const gfx::Rect& bitmap_rect,
81 const std::vector<gfx::Rect>& copy_rects);
83 // This is the connection to the X server where this backing store will be
84 // displayed.
85 Display* const display_;
86 // What flavor, if any, MIT-SHM (X shared memory) support we have.
87 const ui::SharedMemorySupport shared_memory_support_;
88 // If this is true, then we can use Xrender to composite our pixmaps.
89 const bool use_render_;
90 // If |use_render_| is false, this is the number of bits-per-pixel for |depth|
91 int pixmap_bpp_;
92 // if |use_render_| is false, we need the Visual to get the RGB masks.
93 void* const visual_;
94 // This is the depth of the target window.
95 const int visual_depth_;
96 // The parent window (probably a GtkDrawingArea) for this backing store.
97 const XID root_window_;
98 // This is a handle to the server side pixmap which is our backing store.
99 XID pixmap_;
100 // This is the RENDER picture pointing at |pixmap_|.
101 XID picture_;
102 // This is a default graphic context, used in XCopyArea
103 void* pixmap_gc_;
105 DISALLOW_COPY_AND_ASSIGN(BackingStoreGtk);
108 } // namespace content
110 #endif // CONTENT_BROWSER_RENDERER_HOST_BACKING_STORE_GTK_H_