2 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
6 #ifndef UI_GFX_CANVAS_PAINT_LINUX_H_
7 #define UI_GFX_CANVAS_PAINT_LINUX_H_
9 #include "base/logging.h"
10 #include "skia/ext/platform_canvas.h"
11 #include "ui/gfx/canvas.h"
16 // A class designed to translate skia painting into a region in a GdkWindow.
17 // On construction, it will set up a context for painting into, and on
18 // destruction, it will commit it to the GdkWindow.
19 // Note: The created context is always inialized to (0, 0, 0, 0).
20 class UI_EXPORT CanvasSkiaPaint
: public Canvas
{
22 // This constructor assumes the result is opaque.
23 explicit CanvasSkiaPaint(GdkEventExpose
* event
);
24 CanvasSkiaPaint(GdkEventExpose
* event
, bool opaque
);
25 virtual ~CanvasSkiaPaint();
27 // Sets whether the bitmap is composited in such a way that the alpha channel
28 // is honored. This is only useful if you've enabled an RGBA colormap on the
29 // widget. The default is false.
30 void set_composite_alpha(bool composite_alpha
) {
31 composite_alpha_
= composite_alpha
;
34 // Returns true if the invalid region is empty. The caller should call this
35 // function to determine if anything needs painting.
36 bool is_empty() const {
37 return gdk_region_empty(region_
);
40 GdkRectangle
rectangle() const {
42 gdk_region_get_clipbox(region_
, &bounds
);
47 void Init(bool opaque
);
52 // See description above setter.
53 bool composite_alpha_
;
55 // Disallow copy and assign.
56 CanvasSkiaPaint(const CanvasSkiaPaint
&);
57 CanvasSkiaPaint
& operator=(const CanvasSkiaPaint
&);
62 #endif // UI_GFX_CANVAS_PAINT_LINUX_H_