summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-12 00:49:01 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-12 00:49:01 +0000
commita394a55b3563290e918f1e8fa8a50e7de1b2fb3d (patch)
treedbd1691315524d5c3c3fe46d1dfb3c5659525d88 /views
parentc39f9bfe1b02631ff9f439cfd378b9a4c859f4b9 (diff)
downloadchromium_src-a394a55b3563290e918f1e8fa8a50e7de1b2fb3d.zip
chromium_src-a394a55b3563290e918f1e8fa8a50e7de1b2fb3d.tar.gz
chromium_src-a394a55b3563290e918f1e8fa8a50e7de1b2fb3d.tar.bz2
Add --debug-views-paint switch that shows damaged rectangles in red
BUG=none TEST=none Review URL: http://codereview.chromium.org/6489015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74706 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/root_view.cc7
-rw-r--r--views/widget/root_view.h8
-rw-r--r--views/widget/root_view_gtk.cc16
3 files changed, 31 insertions, 0 deletions
diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc
index 83e33e8..0a20f10 100644
--- a/views/widget/root_view.cc
+++ b/views/widget/root_view.cc
@@ -63,6 +63,8 @@ class PaintTask : public Task {
};
const char RootView::kViewClassName[] = "views/RootView";
+// static
+bool RootView::debug_paint_enabled_ = false;
/////////////////////////////////////////////////////////////////////////////
//
@@ -777,6 +779,11 @@ void RootView::ClearPaintRect() {
paint_task_needed_ = false;
}
+// static
+void RootView::EnableDebugPaint() {
+ debug_paint_enabled_ = true;
+}
+
/////////////////////////////////////////////////////////////////////////////
//
// RootView - accessibility
diff --git a/views/widget/root_view.h b/views/widget/root_view.h
index aabf339..4a8f07f 100644
--- a/views/widget/root_view.h
+++ b/views/widget/root_view.h
@@ -189,6 +189,9 @@ class RootView : public View,
void SetGestureManager(GestureManager* g) { gesture_manager_ = g; }
#endif
+ // Enables debug painting. See |debug_paint_enabled_| for details.
+ static void EnableDebugPaint();
+
protected:
// Overridden to properly reset our event propagation member
@@ -353,6 +356,11 @@ class RootView : public View,
// True if we're currently processing paint.
bool is_processing_paint_;
#endif
+
+ // True to enable debug painting. Enabling causes the damaged
+ // region to be painted to flash in red.
+ static bool debug_paint_enabled_;
+
DISALLOW_COPY_AND_ASSIGN(RootView);
};
} // namespace views
diff --git a/views/widget/root_view_gtk.cc b/views/widget/root_view_gtk.cc
index 5edfd63..deffbe4 100644
--- a/views/widget/root_view_gtk.cc
+++ b/views/widget/root_view_gtk.cc
@@ -5,19 +5,35 @@
#include "views/widget/root_view.h"
#include <gtk/gtk.h>
+#include <X11/Xlib.h>
#include "base/logging.h"
+#include "ui/base/x/x11_util.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "views/widget/widget_gtk.h"
namespace views {
void RootView::OnPaint(GdkEventExpose* event) {
+
WidgetGtk* widget = static_cast<WidgetGtk*>(GetWidget());
if (!widget) {
NOTREACHED();
return;
}
+ if (debug_paint_enabled_) {
+ // Using cairo directly because using skia didn't have immediate effect.
+ cairo_t* cr = gdk_cairo_create(event->window);
+ gdk_cairo_region(cr, event->region);
+ cairo_set_source_rgb(cr, 1, 0, 0); // red
+ cairo_rectangle(cr,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_fill(cr);
+ cairo_destroy(cr);
+ // Make sure that users see the red flash.
+ XSync(ui::GetXDisplay(), false /* don't discard events */);
+ }
gfx::Rect scheduled_dirty_rect = GetScheduledPaintRectConstrainedToSize();
gfx::Rect expose_rect = gfx::Rect(event->area);
gfx::CanvasSkiaPaint canvas(event);