Skip to content

Commit

Permalink
gpu: Draw quad debug borders with different colors.
Browse files Browse the repository at this point in the history
Change color of drawquad debug borders based on x-scaling to make
it easier to distinguish neighbouring quads.

BUG=
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2670793004
Cr-Commit-Position: refs/heads/master@{#448364}
  • Loading branch information
DCastagna authored and Commit bot committed Feb 6, 2017
1 parent 1137a30 commit e089ed1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
13 changes: 13 additions & 0 deletions cc/debug/debug_colors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ int DebugColors::DirectPictureBorderWidth(const LayerTreeImpl* tree_impl) {
return Scale(1, tree_impl);
}

// Borders added to GL composited draw quads. This is useful to debug HW
// overlays. When the border disappears, it means we're using an overlay.
// We draw borders in different colors to be able to distinguish neighboring
// quads (often shadows).
SkColor DebugColors::GLCompositedTextureQuadBorderColor(int index) {
const SkColor kColors[] = {SK_ColorBLUE, SK_ColorGREEN, SK_ColorRED,
SK_ColorYELLOW, SK_ColorCYAN, SK_ColorMAGENTA};
return kColors[index % arraysize(kColors)];
}
int DebugColors::GLCompositedTextureQuadBoderWidth() {
return 6;
}

// Compressed tile borders are blue.
SkColor DebugColors::CompressedTileBorderColor() {
return SkColorSetARGB(100, 20, 20, 240);
Expand Down
3 changes: 3 additions & 0 deletions cc/debug/debug_colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ class DebugColors {
static SkColor MissingResizeInvalidations();
static SkColor PictureBorderColor();

static SkColor GLCompositedTextureQuadBorderColor(int index);
static int GLCompositedTextureQuadBoderWidth();

static SkColor HUDBackgroundColor();
static SkColor HUDSeparatorLineColor();
static SkColor HUDIndicatorLineColor();
Expand Down
11 changes: 9 additions & 2 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "build/build_config.h"
#include "cc/base/container_util.h"
#include "cc/base/math_util.h"
#include "cc/debug/debug_colors.h"
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_metadata.h"
#include "cc/output/context_provider.h"
Expand Down Expand Up @@ -2428,9 +2429,15 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) {
program->matrix_location(), 1, false,
reinterpret_cast<float*>(&draw_cache_.matrix_data.front()));

gl_->Uniform4f(program->color_location(), 0.0f, 1.0f, 0.0f, 1.0f);
// Pick a random color based on the scale on X and Y.
int colorIndex = static_cast<int>(draw_cache_.matrix_data.front().data[0] *
draw_cache_.matrix_data.front().data[5]);
SkColor color = DebugColors::GLCompositedTextureQuadBorderColor(colorIndex);

gl_->LineWidth(3.0f);
gl_->Uniform4f(program->color_location(), SkColorGetR(color),
SkColorGetG(color), SkColorGetB(color), 1.0f);

gl_->LineWidth(DebugColors::GLCompositedTextureQuadBoderWidth());
// The indices for the line are stored in the same array as the triangle
// indices.
gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0);
Expand Down

0 comments on commit e089ed1

Please sign in to comment.