| Index: cc/blink/blink_layer_debug_info.cc
|
| diff --git a/cc/blink/blink_layer_debug_info.cc b/cc/blink/blink_layer_debug_info.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fc0811f06acc6804832ef98754fa3b0b32181d68
|
| --- /dev/null
|
| +++ b/cc/blink/blink_layer_debug_info.cc
|
| @@ -0,0 +1,73 @@
|
| +// Copyright 2014 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 "cc/blink/blink_layer_debug_info.h"
|
| +
|
| +#include "cc/base/math_util.h"
|
| +#include "cc/debug/debug_rect_history.h"
|
| +#include "cc/layers/layer.h"
|
| +#include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h"
|
| +#include "third_party/WebKit/public/platform/WebInvalidationDebugAnnotations.h"
|
| +#include "third_party/WebKit/public/platform/WebVector.h"
|
| +#include "ui/gfx/geometry/rect_conversions.h"
|
| +
|
| +namespace cc_blink {
|
| +
|
| +BlinkLayerDebugInfo::BlinkLayerDebugInfo(
|
| + blink::WebGraphicsLayerDebugInfo* debug_info)
|
| + : debug_info_(debug_info) {
|
| +}
|
| +
|
| +BlinkLayerDebugInfo::~BlinkLayerDebugInfo() {
|
| +}
|
| +
|
| +void BlinkLayerDebugInfo::AppendAsTraceFormat(std::string* out) const {
|
| + DCHECK(thread_checker_.CalledOnValidThread());
|
| + blink::WebString web_string;
|
| + debug_info_->appendAsTraceFormat(&web_string);
|
| + out->append(web_string.utf8());
|
| +}
|
| +
|
| +namespace {
|
| +
|
| +cc::DebugRectType WebInvalidationDebugAnnotationsToDebugRectType(
|
| + blink::WebInvalidationDebugAnnotations annotations) {
|
| + if (annotations == blink::WebInvalidationDebugAnnotationsFirstPaint) {
|
| + return cc::FIRST_PAINT_RECT_TYPE;
|
| + }
|
| +
|
| + return cc::PAINT_RECT_TYPE;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +std::vector<cc::DebugRect> BlinkLayerDebugInfo::GetInvalidationRects(
|
| + cc::Layer* layer) const {
|
| + std::vector<cc::DebugRect> rects;
|
| +
|
| + blink::WebVector<blink::WebAnnotatedInvalidationRect> web_rects;
|
| + debug_info_->getAnnotatedInvalidationRects(web_rects);
|
| +
|
| + float width_scale = layer->content_bounds().width() /
|
| + static_cast<float>(layer->bounds().width());
|
| + float height_scale = layer->content_bounds().height() /
|
| + static_cast<float>(layer->bounds().height());
|
| +
|
| + rects.reserve(web_rects.size());
|
| + for (size_t i = 0; i < web_rects.size(); ++i) {
|
| + const blink::WebAnnotatedInvalidationRect& web_rect = web_rects[i];
|
| + cc::DebugRectType type =
|
| + WebInvalidationDebugAnnotationsToDebugRectType(web_rect.annotations);
|
| +
|
| + gfx::Rect update_content_rect = gfx::ScaleToEnclosingRect(
|
| + gfx::ToEnclosingRect(web_rect.rect), width_scale, height_scale);
|
| + gfx::Rect screen_space_rect = cc::MathUtil::MapEnclosingClippedRect(
|
| + layer->screen_space_transform(), update_content_rect);
|
| + rects.push_back(cc::DebugRect(type, screen_space_rect));
|
| + }
|
| +
|
| + return rects;
|
| +}
|
| +
|
| +} // namespace cc_blink
|
|
|