diff options
20 files changed, 248 insertions, 113 deletions
diff --git a/cc/blink/web_layer_impl.cc b/cc/blink/web_layer_impl.cc index bde0bdf..726cfa6 100644 --- a/cc/blink/web_layer_impl.cc +++ b/cc/blink/web_layer_impl.cc @@ -25,6 +25,8 @@ #include "cc/trees/layer_tree_host.h" #include "third_party/WebKit/public/platform/WebFloatPoint.h" #include "third_party/WebKit/public/platform/WebFloatRect.h" +#include "third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h" +#include "third_party/WebKit/public/platform/WebLayerClient.h" #include "third_party/WebKit/public/platform/WebLayerPositionConstraint.h" #include "third_party/WebKit/public/platform/WebLayerScrollClient.h" #include "third_party/WebKit/public/platform/WebSize.h" @@ -52,15 +54,20 @@ base::LazyInstance<cc::LayerSettings> g_layer_settings = WebLayerImpl::WebLayerImpl() : layer_(Layer::Create(LayerSettings())), contents_opaque_is_fixed_(false) { + web_layer_client_ = nullptr; + layer_->SetLayerClient(this); } WebLayerImpl::WebLayerImpl(scoped_refptr<Layer> layer) : layer_(layer), contents_opaque_is_fixed_(false) { + web_layer_client_ = nullptr; + layer_->SetLayerClient(this); } WebLayerImpl::~WebLayerImpl() { if (animation_delegate_adapter_.get()) layer_->set_layer_animation_delegate(nullptr); + web_layer_client_ = nullptr; layer_->SetLayerClient(nullptr); } @@ -486,12 +493,39 @@ bool WebLayerImpl::isOrphan() const { return !layer_->layer_tree_host(); } -void WebLayerImpl::setLayerClient(cc::LayerClient* client) { - layer_->SetLayerClient(client); +void WebLayerImpl::setWebLayerClient(blink::WebLayerClient* client) { + web_layer_client_ = client; } -const cc::Layer* WebLayerImpl::ccLayer() const { - return layer_.get(); +class TracedDebugInfo : public base::trace_event::ConvertableToTraceFormat { + public: + // This object takes ownership of the debug_info object. + explicit TracedDebugInfo(blink::WebGraphicsLayerDebugInfo* debug_info) + : debug_info_(debug_info) {} + void AppendAsTraceFormat(std::string* out) const override { + DCHECK(thread_checker_.CalledOnValidThread()); + blink::WebString web_string; + debug_info_->appendAsTraceFormat(&web_string); + out->append(web_string.utf8()); + } + + private: + ~TracedDebugInfo() override {} + scoped_ptr<blink::WebGraphicsLayerDebugInfo> debug_info_; + base::ThreadChecker thread_checker_; +}; + +scoped_refptr<base::trace_event::ConvertableToTraceFormat> +WebLayerImpl::TakeDebugInfo() { + if (!web_layer_client_) + return nullptr; + blink::WebGraphicsLayerDebugInfo* debug_info = + web_layer_client_->takeDebugInfoFor(this); + + if (debug_info) + return new TracedDebugInfo(debug_info); + else + return nullptr; } void WebLayerImpl::setScrollParent(blink::WebLayer* parent) { diff --git a/cc/blink/web_layer_impl.h b/cc/blink/web_layer_impl.h index eb5be7e..e9f79c0 100644 --- a/cc/blink/web_layer_impl.h +++ b/cc/blink/web_layer_impl.h @@ -27,6 +27,7 @@ namespace blink { class WebFilterOperations; +class WebLayerClient; struct WebFloatRect; } @@ -45,7 +46,7 @@ namespace cc_blink { class WebToCCAnimationDelegateAdapter; -class WebLayerImpl : public blink::WebLayer { +class WebLayerImpl : public blink::WebLayer, public cc::LayerClient { public: CC_BLINK_EXPORT WebLayerImpl(); CC_BLINK_EXPORT explicit WebLayerImpl(scoped_refptr<cc::Layer>); @@ -145,14 +146,18 @@ class WebLayerImpl : public blink::WebLayer { blink::WebLayerPositionConstraint positionConstraint() const override; void setScrollClient(blink::WebLayerScrollClient* client) override; bool isOrphan() const override; - void setLayerClient(cc::LayerClient* client) override; - const cc::Layer* ccLayer() const override; + void setWebLayerClient(blink::WebLayerClient* client) override; + + // LayerClient implementation. + scoped_refptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo() + override; void setScrollParent(blink::WebLayer* parent) override; void setClipParent(blink::WebLayer* parent) override; protected: scoped_refptr<cc::Layer> layer_; + blink::WebLayerClient* web_layer_client_; bool contents_opaque_is_fixed_; diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index d6b1fb0..68b34df 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc @@ -1531,7 +1531,7 @@ bool Layer::IsSuitableForGpuRasterization() const { scoped_refptr<base::trace_event::ConvertableToTraceFormat> Layer::TakeDebugInfo() { if (client_) - return client_->TakeDebugInfo(this); + return client_->TakeDebugInfo(); else return nullptr; } diff --git a/cc/layers/layer_client.h b/cc/layers/layer_client.h index 524399d..bcdf1c3 100644 --- a/cc/layers/layer_client.h +++ b/cc/layers/layer_client.h @@ -5,6 +5,8 @@ #ifndef CC_LAYERS_LAYER_CLIENT_H_ #define CC_LAYERS_LAYER_CLIENT_H_ +#include <string> + #include "base/memory/ref_counted.h" #include "cc/base/cc_export.h" @@ -16,19 +18,14 @@ class ConvertableToTraceFormat; namespace cc { -class Layer; - class CC_EXPORT LayerClient { public: // Returns a pointer to a debug info object, if one has been computed. // If not, returns nullptr. // If the returned pointer is non-nullptr, the caller takes // ownership of the pointer. - // - // A pointer to the layer is provided for the convenience of layer clients - // which service multiple layers. virtual scoped_refptr<base::trace_event::ConvertableToTraceFormat> - TakeDebugInfo(Layer* layer) = 0; + TakeDebugInfo() = 0; protected: virtual ~LayerClient() {} diff --git a/third_party/WebKit/Source/core/core.gyp b/third_party/WebKit/Source/core/core.gyp index a72f8dc..9eb50c8 100644 --- a/third_party/WebKit/Source/core/core.gyp +++ b/third_party/WebKit/Source/core/core.gyp @@ -706,7 +706,6 @@ '../platform/platform_generated.gyp:make_platform_generated', '../wtf/wtf.gyp:wtf', - '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/gin/gin.gyp:gin', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/libxml/libxml.gyp:libxml', @@ -721,7 +720,6 @@ 'export_dependent_settings': [ '../platform/blink_platform.gyp:blink_platform', '../wtf/wtf.gyp:wtf', - '<(DEPTH)/base/base.gyp:base', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/npapi/npapi.gyp:npapi', '<(DEPTH)/third_party/qcms/qcms.gyp:qcms', diff --git a/third_party/WebKit/Source/platform/BUILD.gn b/third_party/WebKit/Source/platform/BUILD.gn index 19e6cbc..ec882fe 100644 --- a/third_party/WebKit/Source/platform/BUILD.gn +++ b/third_party/WebKit/Source/platform/BUILD.gn @@ -196,8 +196,6 @@ component("platform") { ] public_deps = [ - "//base", - "//cc", "//gpu/command_buffer/client:gles2_c_lib", "//skia", "//third_party:jpeg", @@ -211,10 +209,10 @@ component("platform") { ] deps = [ ":make_platform_generated", - "//third_party/WebKit/Source/platform/heap", - "//third_party/WebKit/Source/wtf", "//third_party/harfbuzz-ng", "//third_party/icu", + "//third_party/WebKit/Source/wtf", + "//third_party/WebKit/Source/platform/heap", ] if (is_mac) { @@ -351,11 +349,11 @@ test("heap_unittests") { "//base", "//base/allocator", "//base/test:test_support", - "//content/test:test_support", "//testing/gmock", "//testing/gtest", "//third_party/WebKit/Source/wtf", "//third_party/WebKit/Source/wtf:test_support", + "//content/test:test_support", ] if (is_android) { apk_deps = [ @@ -402,9 +400,9 @@ test("platform_unittests") { "//skia", "//testing/gmock", "//testing/gtest", + "//third_party/harfbuzz-ng", "//third_party/WebKit/Source/wtf", "//third_party/WebKit/Source/wtf:test_support", - "//third_party/harfbuzz-ng", "//url", ] diff --git a/third_party/WebKit/Source/platform/DEPS b/third_party/WebKit/Source/platform/DEPS index 015df67..99c3cc6f 100644 --- a/third_party/WebKit/Source/platform/DEPS +++ b/third_party/WebKit/Source/platform/DEPS @@ -1,6 +1,4 @@ include_rules = [ - "+base/memory", - "+base/trace_event", "+mozilla", "+platform", "+public/platform", diff --git a/third_party/WebKit/Source/platform/blink_platform.gyp b/third_party/WebKit/Source/platform/blink_platform.gyp index a396865..701bded 100644 --- a/third_party/WebKit/Source/platform/blink_platform.gyp +++ b/third_party/WebKit/Source/platform/blink_platform.gyp @@ -182,8 +182,6 @@ 'blink_common', 'blink_heap_asm_stubs', 'blink_prerequisites', - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/cc/cc.gyp:cc', '<(DEPTH)/gpu/gpu.gyp:gles2_c_lib', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/icu/icu.gyp:icui18n', @@ -199,8 +197,6 @@ '<(libjpeg_gyp_path):libjpeg', ], 'export_dependent_settings': [ - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/cc/cc.gyp:cc', '<(DEPTH)/gpu/gpu.gyp:gles2_c_lib', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/libpng/libpng.gyp:libpng', diff --git a/third_party/WebKit/Source/platform/graphics/DEPS b/third_party/WebKit/Source/platform/graphics/DEPS deleted file mode 100644 index 8d825ff..0000000 --- a/third_party/WebKit/Source/platform/graphics/DEPS +++ /dev/null @@ -1,4 +0,0 @@ -include_rules = [ - "+cc", - "-cc/blink", -] diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp index 6acf656..7a664ab 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.cpp @@ -28,9 +28,7 @@ #include "SkImageFilter.h" #include "SkMatrix44.h" -#include "base/trace_event/trace_event_argument.h" #include "platform/DragImage.h" -#include "platform/JSONValues.h" #include "platform/TraceEvent.h" #include "platform/geometry/FloatRect.h" #include "platform/geometry/LayoutRect.h" @@ -51,13 +49,13 @@ #include "public/platform/WebFilterOperations.h" #include "public/platform/WebFloatPoint.h" #include "public/platform/WebFloatRect.h" +#include "public/platform/WebGraphicsLayerDebugInfo.h" #include "public/platform/WebLayer.h" #include "public/platform/WebPoint.h" #include "public/platform/WebSize.h" #include "wtf/CurrentTime.h" #include "wtf/HashMap.h" #include "wtf/HashSet.h" -#include "wtf/text/StringUTF8Adaptor.h" #include "wtf/text/WTFString.h" #include <algorithm> @@ -126,7 +124,7 @@ GraphicsLayer::GraphicsLayer(GraphicsLayerClient* client) m_contentLayerDelegate = adoptPtr(new ContentLayerDelegate(this)); m_layer = adoptPtr(Platform::current()->compositorSupport()->createContentLayer(m_contentLayerDelegate.get())); m_layer->layer()->setDrawsContent(m_drawsContent && m_contentsVisible); - m_layer->layer()->setLayerClient(this); + m_layer->layer()->setWebLayerClient(this); // TODO(rbyers): Expose control over this to the web - crbug.com/489802: setScrollBlocksOn(WebScrollBlocksOnStartTouch | WebScrollBlocksOnWheelEvent); @@ -456,7 +454,7 @@ void GraphicsLayer::setupContentsLayer(WebLayer* contentsLayer) m_contentsLayer = contentsLayer; m_contentsLayerId = m_contentsLayer->id(); - m_contentsLayer->setLayerClient(this); + m_contentsLayer->setWebLayerClient(this); m_contentsLayer->setTransformOrigin(FloatPoint3D()); m_contentsLayer->setUseParentBackfaceVisibility(true); @@ -487,6 +485,13 @@ GraphicsLayerDebugInfo& GraphicsLayer::debugInfo() return m_debugInfo; } +WebGraphicsLayerDebugInfo* GraphicsLayer::takeDebugInfoFor(WebLayer* layer) +{ + GraphicsLayerDebugInfo* clone = m_debugInfo.clone(); + clone->setDebugName(debugName(layer)); + return clone; +} + WebLayer* GraphicsLayer::contentsLayerIfRegistered() { clearContentsLayerIfUnregistered(); @@ -766,12 +771,7 @@ String GraphicsLayer::layerTreeAsText(LayerTreeFlags flags) const return json->toPrettyJSONString(); } -static const cc::Layer* ccLayerForWebLayer(const WebLayer* webLayer) -{ - return webLayer ? webLayer->ccLayer() : nullptr; -} - -String GraphicsLayer::debugName(cc::Layer* layer) const +String GraphicsLayer::debugName(WebLayer* webLayer) const { String name; if (!m_client) @@ -779,17 +779,17 @@ String GraphicsLayer::debugName(cc::Layer* layer) const String highlightDebugName; for (size_t i = 0; i < m_linkHighlights.size(); ++i) { - if (layer == ccLayerForWebLayer(m_linkHighlights[i]->layer())) { + if (webLayer == m_linkHighlights[i]->layer()) { highlightDebugName = "LinkHighlight[" + String::number(i) + "] for " + m_client->debugName(this); break; } } - if (layer == ccLayerForWebLayer(m_contentsLayer)) { + if (webLayer == m_contentsLayer) { name = "ContentsLayer for " + m_client->debugName(this); } else if (!highlightDebugName.isEmpty()) { name = highlightDebugName; - } else if (layer == ccLayerForWebLayer(m_layer->layer())) { + } else if (webLayer == m_layer->layer()) { name = m_client->debugName(this); } else { ASSERT_NOT_REACHED(); @@ -1143,7 +1143,7 @@ void GraphicsLayer::addLinkHighlight(LinkHighlight* linkHighlight) { ASSERT(linkHighlight && !m_linkHighlights.contains(linkHighlight)); m_linkHighlights.append(linkHighlight); - linkHighlight->layer()->setLayerClient(this); + linkHighlight->layer()->setWebLayerClient(this); updateChildList(); } @@ -1191,13 +1191,6 @@ void GraphicsLayer::didScroll() } } -scoped_refptr<base::trace_event::ConvertableToTraceFormat> GraphicsLayer::TakeDebugInfo(cc::Layer* layer) -{ - scoped_refptr<base::trace_event::TracedValue> tracedValue = m_debugInfo.asTracedValue(); - tracedValue->SetString("layer_name", WTF::StringUTF8Adaptor(debugName(layer)).asStringPiece()); - return tracedValue; -} - PaintController* GraphicsLayer::paintController() { if (!m_paintController) diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h index 3a8ef51..6e58663 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayer.h @@ -27,7 +27,6 @@ #ifndef GraphicsLayer_h #define GraphicsLayer_h -#include "cc/layers/layer_client.h" #include "platform/PlatformExport.h" #include "platform/geometry/FloatPoint.h" #include "platform/geometry/FloatPoint3D.h" @@ -48,6 +47,7 @@ #include "public/platform/WebCompositorAnimationDelegate.h" #include "public/platform/WebContentLayer.h" #include "public/platform/WebImageLayer.h" +#include "public/platform/WebLayerClient.h" #include "public/platform/WebLayerScrollClient.h" #include "public/platform/WebScrollBlocksOn.h" #include "third_party/skia/include/core/SkPaint.h" @@ -75,7 +75,7 @@ typedef Vector<GraphicsLayer*, 64> GraphicsLayerVector; // GraphicsLayer is an abstraction for a rendering surface with backing store, // which may have associated transformation and animations. -class PLATFORM_EXPORT GraphicsLayer : public GraphicsContextPainter, public WebCompositorAnimationDelegate, public WebLayerScrollClient, public cc::LayerClient { +class PLATFORM_EXPORT GraphicsLayer : public GraphicsContextPainter, public WebCompositorAnimationDelegate, public WebLayerScrollClient, public WebLayerClient { WTF_MAKE_NONCOPYABLE(GraphicsLayer); USING_FAST_MALLOC(GraphicsLayer); public: static PassOwnPtr<GraphicsLayer> create(GraphicsLayerFactory*, GraphicsLayerClient*); @@ -84,6 +84,9 @@ public: GraphicsLayerClient* client() const { return m_client; } + // WebLayerClient implementation. + WebGraphicsLayerDebugInfo* takeDebugInfoFor(WebLayer*) override; + GraphicsLayerDebugInfo& debugInfo(); void setCompositingReasons(CompositingReasons); @@ -252,9 +255,6 @@ public: // WebLayerScrollClient implementation. void didScroll() override; - // cc::LayerClient implementation. - scoped_refptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo(cc::Layer*) override; - PaintController* paintController() override; // Exposed for tests. @@ -267,7 +267,7 @@ public: String debugName() const { return m_client->debugName(this); } protected: - String debugName(cc::Layer*) const; + String debugName(WebLayer*) const; explicit GraphicsLayer(GraphicsLayerClient*); // GraphicsLayerFactoryChromium that wants to create a GraphicsLayer need to be friends. diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp index 6e60f15..4c2c76e 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.cpp @@ -20,7 +20,8 @@ #include "config.h" #include "platform/graphics/GraphicsLayerDebugInfo.h" -#include "base/trace_event/trace_event_argument.h" +#include "public/platform/WebGraphicsLayerDebugInfo.h" +#include "wtf/text/CString.h" namespace blink { @@ -32,50 +33,69 @@ GraphicsLayerDebugInfo::GraphicsLayerDebugInfo() GraphicsLayerDebugInfo::~GraphicsLayerDebugInfo() { } -scoped_refptr<base::trace_event::TracedValue> GraphicsLayerDebugInfo::asTracedValue() const +void GraphicsLayerDebugInfo::appendAsTraceFormat(WebString* out) const { - scoped_refptr<base::trace_event::TracedValue> tracedValue = new base::trace_event::TracedValue; - appendAnnotatedInvalidateRects(tracedValue.get()); - appendCompositingReasons(tracedValue.get()); - appendOwnerNodeId(tracedValue.get()); - return tracedValue; + RefPtr<JSONObject> jsonObject = JSONObject::create(); + appendAnnotatedInvalidateRects(jsonObject.get()); + appendCompositingReasons(jsonObject.get()); + appendDebugName(jsonObject.get()); + appendOwnerNodeId(jsonObject.get()); + *out = jsonObject->toJSONString(); } -void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(base::trace_event::TracedValue* tracedValue) const +GraphicsLayerDebugInfo* GraphicsLayerDebugInfo::clone() const { - tracedValue->BeginArray("annotated_invalidation_rects"); + GraphicsLayerDebugInfo* toReturn = new GraphicsLayerDebugInfo(); + toReturn->setCompositingReasons(m_compositingReasons); + toReturn->setOwnerNodeId(m_ownerNodeId); + toReturn->m_invalidations = m_invalidations; + toReturn->m_previousInvalidations = m_previousInvalidations; + return toReturn; +} + +void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRects(JSONObject* jsonObject) const +{ + RefPtr<JSONArray> jsonArray = JSONArray::create(); for (const auto& annotatedRect : m_previousInvalidations) { + RefPtr<JSONObject> rectContainer = JSONObject::create(); + RefPtr<JSONArray> rectArray = JSONArray::create(); const FloatRect& rect = annotatedRect.rect; - tracedValue->BeginDictionary(); - tracedValue->BeginArray("geometry_rect"); - tracedValue->AppendDouble(rect.x()); - tracedValue->AppendDouble(rect.y()); - tracedValue->AppendDouble(rect.width()); - tracedValue->AppendDouble(rect.height()); - tracedValue->EndArray(); - tracedValue->SetString("reason", paintInvalidationReasonToString(annotatedRect.reason)); - tracedValue->EndDictionary(); + rectArray->pushNumber(rect.x()); + rectArray->pushNumber(rect.y()); + rectArray->pushNumber(rect.width()); + rectArray->pushNumber(rect.height()); + rectContainer->setArray("geometry_rect", rectArray); + rectContainer->setString("reason", paintInvalidationReasonToString(annotatedRect.reason)); + jsonArray->pushObject(rectContainer); } - tracedValue->EndArray(); + jsonObject->setArray("annotated_invalidation_rects", jsonArray); } -void GraphicsLayerDebugInfo::appendCompositingReasons(base::trace_event::TracedValue* tracedValue) const +void GraphicsLayerDebugInfo::appendCompositingReasons(JSONObject* jsonObject) const { - tracedValue->BeginArray("compositing_reasons"); + RefPtr<JSONArray> jsonArray = JSONArray::create(); for (size_t i = 0; i < kNumberOfCompositingReasons; ++i) { if (!(m_compositingReasons & kCompositingReasonStringMap[i].reason)) continue; - tracedValue->AppendString(kCompositingReasonStringMap[i].description); + jsonArray->pushString(kCompositingReasonStringMap[i].description); } - tracedValue->EndArray(); + jsonObject->setArray("compositing_reasons", jsonArray); +} + +void GraphicsLayerDebugInfo::appendDebugName(JSONObject* jsonObject) const +{ + if (m_debugName.isEmpty()) + return; + + jsonObject->setString("layer_name", m_debugName); } -void GraphicsLayerDebugInfo::appendOwnerNodeId(base::trace_event::TracedValue* tracedValue) const +void GraphicsLayerDebugInfo::appendOwnerNodeId(JSONObject* jsonObject) const { if (!m_ownerNodeId) return; - tracedValue->SetInteger("owner_node", m_ownerNodeId); + jsonObject->setNumber("owner_node", m_ownerNodeId); } void GraphicsLayerDebugInfo::appendAnnotatedInvalidateRect(const FloatRect& rect, PaintInvalidationReason invalidationReason) diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.h b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.h index b5ebc2c..be57a28 100644 --- a/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.h +++ b/third_party/WebKit/Source/platform/graphics/GraphicsLayerDebugInfo.h @@ -31,27 +31,26 @@ #ifndef GraphicsLayerDebugInfo_h #define GraphicsLayerDebugInfo_h -#include "base/memory/ref_counted.h" +#include "platform/JSONValues.h" #include "platform/geometry/FloatRect.h" #include "platform/graphics/CompositingReasons.h" #include "platform/graphics/PaintInvalidationReason.h" -#include "wtf/Vector.h" +#include "public/platform/WebGraphicsLayerDebugInfo.h" -namespace base { -namespace trace_event { -class TracedValue; -} -} +#include "wtf/Vector.h" namespace blink { -class GraphicsLayerDebugInfo { +class GraphicsLayerDebugInfo final : public WebGraphicsLayerDebugInfo { public: GraphicsLayerDebugInfo(); - ~GraphicsLayerDebugInfo(); + ~GraphicsLayerDebugInfo() override; + + void appendAsTraceFormat(WebString* out) const override; - scoped_refptr<base::trace_event::TracedValue> asTracedValue() const; + GraphicsLayerDebugInfo* clone() const; + void setDebugName(const String& name) { m_debugName = name; } CompositingReasons compositingReasons() const { return m_compositingReasons; } void setCompositingReasons(CompositingReasons reasons) { m_compositingReasons = reasons; } void setOwnerNodeId(int id) { m_ownerNodeId = id; } @@ -60,15 +59,17 @@ public: void clearAnnotatedInvalidateRects(); private: - void appendAnnotatedInvalidateRects(base::trace_event::TracedValue*) const; - void appendCompositingReasons(base::trace_event::TracedValue*) const; - void appendOwnerNodeId(base::trace_event::TracedValue*) const; + void appendAnnotatedInvalidateRects(JSONObject*) const; + void appendCompositingReasons(JSONObject*) const; + void appendDebugName(JSONObject*) const; + void appendOwnerNodeId(JSONObject*) const; struct AnnotatedInvalidationRect { FloatRect rect; PaintInvalidationReason reason; }; + String m_debugName; CompositingReasons m_compositingReasons; int m_ownerNodeId; Vector<AnnotatedInvalidationRect> m_invalidations; diff --git a/third_party/WebKit/public/blink_headers.gypi b/third_party/WebKit/public/blink_headers.gypi index c6a83ca..1385663 100644 --- a/third_party/WebKit/public/blink_headers.gypi +++ b/third_party/WebKit/public/blink_headers.gypi @@ -110,6 +110,7 @@ "platform/WebGestureDevice.h", "platform/WebGraphicsContext3D.h", "platform/WebGraphicsContext3DProvider.h", + "platform/WebGraphicsLayerDebugInfo.h", "platform/WebHTTPBody.h", "platform/WebHTTPHeaderVisitor.h", "platform/WebHTTPLoadInfo.h", @@ -120,6 +121,7 @@ "platform/WebInbandTextTrack.h", "platform/WebInbandTextTrackClient.h", "platform/WebLayer.h", + "platform/WebLayerClient.h", "platform/WebLayerPositionConstraint.h", "platform/WebLayerScrollClient.h", "platform/WebLayerTreeView.h", diff --git a/third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h b/third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h new file mode 100644 index 0000000..15265eb --- /dev/null +++ b/third_party/WebKit/public/platform/WebGraphicsLayerDebugInfo.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebGraphicsLayerDebugInfo_h +#define WebGraphicsLayerDebugInfo_h + +#include "public/platform/WebString.h" + +namespace blink { + +template <typename T> +class WebVector; + +class WebGraphicsLayerDebugInfo { +public: + virtual void appendAsTraceFormat(WebString* out) const = 0; + virtual ~WebGraphicsLayerDebugInfo() { } +}; + +} // namespace blink + +#endif // WebGraphicsLayerDebugInfo_h + diff --git a/third_party/WebKit/public/platform/WebLayer.h b/third_party/WebKit/public/platform/WebLayer.h index 1e1f1ed..b0ebba5 100644 --- a/third_party/WebKit/public/platform/WebLayer.h +++ b/third_party/WebKit/public/platform/WebLayer.h @@ -42,14 +42,10 @@ class SkMatrix44; class SkImageFilter; -namespace cc { -class Layer; -class LayerClient; -} - namespace blink { class WebCompositorAnimationDelegate; class WebFilterOperations; +class WebLayerClient; class WebLayerScrollClient; struct WebFloatPoint; struct WebLayerPositionConstraint; @@ -242,11 +238,7 @@ public: // True if the layer is not part of a tree attached to a WebLayerTreeView. virtual bool isOrphan() const = 0; - // Sets the cc-side layer client. - virtual void setLayerClient(cc::LayerClient*) = 0; - - // Gets the underlying cc layer. - virtual const cc::Layer* ccLayer() const = 0; + virtual void setWebLayerClient(WebLayerClient*) = 0; }; } // namespace blink diff --git a/third_party/WebKit/public/platform/WebLayerClient.h b/third_party/WebKit/public/platform/WebLayerClient.h new file mode 100644 index 0000000..74cd3f0 --- /dev/null +++ b/third_party/WebKit/public/platform/WebLayerClient.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebLayerClient_h +#define WebLayerClient_h + +#include "WebCommon.h" + +namespace blink { + +class WebGraphicsLayerDebugInfo; + +class BLINK_PLATFORM_EXPORT WebLayerClient { +public: + // Returns a pointer to a debug info object, if one has been computed. + // If not, returns 0. If the returned pointer is non-zero, the caller takes + // ownership of the pointer. The parameter allows us to return WebLayer- + // specific information, too (only the debug name for now). + virtual WebGraphicsLayerDebugInfo* takeDebugInfoFor(WebLayer*) = 0; + +protected: + virtual ~WebLayerClient() { } +}; + +} // namespace blink + +#endif // WebLayerClient_h + diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 7559a9a..5144ec9 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -812,8 +812,8 @@ class LayerDebugInfo : public base::trace_event::ConvertableToTraceFormat { std::string name_; }; -scoped_refptr<base::trace_event::ConvertableToTraceFormat> Layer::TakeDebugInfo( - cc::Layer* layer) { +scoped_refptr<base::trace_event::ConvertableToTraceFormat> +Layer::TakeDebugInfo() { return new LayerDebugInfo(name_); } diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index ddc82c7..d6f593a 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -369,8 +369,8 @@ class COMPOSITOR_EXPORT Layer bool force_render_surface() const { return force_render_surface_; } // LayerClient - scoped_refptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo( - cc::Layer* layer) override; + scoped_refptr<base::trace_event::ConvertableToTraceFormat> TakeDebugInfo() + override; // LayerAnimationEventObserver void OnAnimationStarted(const cc::AnimationEvent& event) override; diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index a6c14b4..935bfa7 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -692,7 +692,7 @@ TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) { std::string name = "\"\'\\/\b\f\n\r\t\n"; layer->set_name(name); scoped_refptr<base::trace_event::ConvertableToTraceFormat> debug_info = - layer->TakeDebugInfo(layer->cc_layer_for_testing()); + layer->TakeDebugInfo(); EXPECT_TRUE(debug_info.get()); std::string json; debug_info->AppendAsTraceFormat(&json); |