summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorvollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-03 16:51:43 +0000
committervollick@chromium.org <vollick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-03 16:51:43 +0000
commitbc583affec310a6891538a5522c38a3cdd60670d (patch)
treeec0e54b3a6a29a81cb04143713aefe6850d7acd2 /ui
parent3fd0371cdb19b4315f0af66d5e4c7ff83a2de0cf (diff)
downloadchromium_src-bc583affec310a6891538a5522c38a3cdd60670d.zip
chromium_src-bc583affec310a6891538a5522c38a3cdd60670d.tar.gz
chromium_src-bc583affec310a6891538a5522c38a3cdd60670d.tar.bz2
Overdraw debugging can be enabled with the --enable-compositor-overdraw-debugging flag
Some debugging code to help identify areas of overdraw BUG=None TEST=None Review URL: http://codereview.chromium.org/7945012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/compositor/compositor.gyp2
-rw-r--r--ui/gfx/compositor/compositor_gl.cc121
-rw-r--r--ui/gfx/compositor/compositor_switches.cc12
-rw-r--r--ui/gfx/compositor/compositor_switches.h17
4 files changed, 117 insertions, 35 deletions
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp
index 5a940ae..1b1aeb3 100644
--- a/ui/gfx/compositor/compositor.gyp
+++ b/ui/gfx/compositor/compositor.gyp
@@ -44,6 +44,8 @@
'compositor_cc.h',
'compositor_observer.h',
'compositor_stub.cc',
+ 'compositor_switches.cc',
+ 'compositor_switches.h',
'compositor_win.cc',
'layer.cc',
'layer.h',
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index 92ada06..3d53d28 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/compositor/compositor_gl.h"
#include "base/basictypes.h"
+#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/debug/trace_event.h"
#include "base/logging.h"
@@ -17,6 +18,7 @@
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkScalar.h"
+#include "ui/gfx/compositor/compositor_switches.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
#include "ui/gfx/gl/gl_bindings.h"
@@ -116,23 +118,44 @@ GLuint CompileShader(GLenum type, const GLchar* source) {
}
bool TextureProgramNoSwizzleGL::Initialize() {
- const GLchar* frag_shader_source =
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "uniform float u_alpha;"
- "uniform sampler2D u_tex;"
- "varying vec2 v_texCoord;"
- "void main()"
- "{"
- " gl_FragColor = texture2D(u_tex, v_texCoord);"
- " if (u_alpha > 0.0)"
- " gl_FragColor.a = u_alpha;"
- " else"
- " gl_FragColor.a = gl_FragColor.a * -u_alpha;"
- "}";
-
- frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ const bool debug_overdraw = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableCompositorOverdrawDebugging);
+
+ if (debug_overdraw) {
+ const GLchar* frag_shader_source =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "uniform sampler2D u_tex;"
+ "varying vec2 v_texCoord;"
+ "void main()"
+ "{"
+ " gl_FragColor = texture2D(u_tex, v_texCoord);"
+ " gl_FragColor.a = 1.0;"
+ " gl_FragColor = gl_FragColor * 0.25;"
+ " gl_FragColor = gl_FragColor + vec4(0.75, 0.75, 0.75, 0.75);"
+ " gl_FragColor = gl_FragColor * 0.3333333;"
+ "}";
+ frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ } else {
+ const GLchar* frag_shader_source =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "uniform float u_alpha;"
+ "uniform sampler2D u_tex;"
+ "varying vec2 v_texCoord;"
+ "void main()"
+ "{"
+ " gl_FragColor = texture2D(u_tex, v_texCoord);"
+ " if (u_alpha > 0.0)"
+ " gl_FragColor.a = u_alpha;"
+ " else"
+ " gl_FragColor.a = gl_FragColor.a * -u_alpha;"
+ "}";
+ frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ }
+
if (!frag_shader_)
return false;
@@ -140,23 +163,44 @@ bool TextureProgramNoSwizzleGL::Initialize() {
}
bool TextureProgramSwizzleGL::Initialize() {
- const GLchar* frag_shader_source =
- "#ifdef GL_ES\n"
- "precision mediump float;\n"
- "#endif\n"
- "uniform float u_alpha;"
- "uniform sampler2D u_tex;"
- "varying vec2 v_texCoord;"
- "void main()"
- "{"
- " gl_FragColor = texture2D(u_tex, v_texCoord).zyxw;"
- " if (u_alpha > 0.0)"
- " gl_FragColor.a = u_alpha;"
- " else"
- " gl_FragColor.a = gl_FragColor.a * -u_alpha;"
- "}";
-
- frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ const bool debug_overdraw = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableCompositorOverdrawDebugging);
+
+ if (debug_overdraw) {
+ const GLchar* frag_shader_source =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "uniform sampler2D u_tex;"
+ "varying vec2 v_texCoord;"
+ "void main()"
+ "{"
+ " gl_FragColor = texture2D(u_tex, v_texCoord).zyxw;"
+ " gl_FragColor.a = 1.0;"
+ " gl_FragColor = gl_FragColor * 0.25;"
+ " gl_FragColor = gl_FragColor + vec4(0.75, 0.75, 0.75, 0.75);"
+ " gl_FragColor = gl_FragColor * 0.3333333;"
+ "}";
+ frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ } else {
+ const GLchar* frag_shader_source =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "uniform float u_alpha;"
+ "uniform sampler2D u_tex;"
+ "varying vec2 v_texCoord;"
+ "void main()"
+ "{"
+ " gl_FragColor = texture2D(u_tex, v_texCoord).zyxw;"
+ " if (u_alpha > 0.0)"
+ " gl_FragColor.a = u_alpha;"
+ " else"
+ " gl_FragColor.a = gl_FragColor.a * -u_alpha;"
+ "}";
+ frag_shader_ = CompileShader(GL_FRAGMENT_SHADER, frag_shader_source);
+ }
+
if (!frag_shader_)
return false;
@@ -499,7 +543,14 @@ CompositorGL::CompositorGL(CompositorDelegate* delegate,
gl_context_->MakeCurrent(gl_surface_.get());
gl_context_->SetSwapInterval(1);
glColorMask(true, true, true, true);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ const bool debug_overdraw = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableCompositorOverdrawDebugging);
+
+ if (debug_overdraw)
+ glBlendFunc(GL_ONE, GL_ONE);
+ else
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
CompositorGL::~CompositorGL() {
diff --git a/ui/gfx/compositor/compositor_switches.cc b/ui/gfx/compositor/compositor_switches.cc
new file mode 100644
index 0000000..13c9bc6
--- /dev/null
+++ b/ui/gfx/compositor/compositor_switches.cc
@@ -0,0 +1,12 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/compositor/compositor_switches.h"
+
+namespace switches {
+
+const char kEnableCompositorOverdrawDebugging[] =
+ "enable-compositor-overdraw-debugging";
+
+} // namespace switches
diff --git a/ui/gfx/compositor/compositor_switches.h b/ui/gfx/compositor/compositor_switches.h
new file mode 100644
index 0000000..df7a2e3
--- /dev/null
+++ b/ui/gfx/compositor/compositor_switches.h
@@ -0,0 +1,17 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GFX_COMPOSITOR_SWITCHES_H_
+#define UI_GFX_COMPOSITOR_SWITCHES_H_
+#pragma once
+
+#include "ui/gfx/compositor/compositor_export.h"
+
+namespace switches {
+
+COMPOSITOR_EXPORT extern const char kEnableCompositorOverdrawDebugging[];
+
+} // namespace switches
+
+#endif // UI_GFX_COMPOSITOR_SWITCHES_H_