diff options
author | pdr@chromium.org <pdr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 11:11:18 +0000 |
---|---|---|
committer | pdr@chromium.org <pdr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 11:11:18 +0000 |
commit | aafcd2763d9981c3dc9421ab5fbd027a113c340b (patch) | |
tree | 33e3d3b8f0afc3e59ef25dcf18ac2f72472cba73 /cc/debug | |
parent | a8228251b80841509838bf34cbd047d5d4718823 (diff) | |
download | chromium_src-aafcd2763d9981c3dc9421ab5fbd027a113c340b.zip chromium_src-aafcd2763d9981c3dc9421ab5fbd027a113c340b.tar.gz chromium_src-aafcd2763d9981c3dc9421ab5fbd027a113c340b.tar.bz2 |
This patch adds picture tracing to cc/picture.cc. The important bits of this patch fall in two categories:
1) Picture::Raster has been instrumented with trace calls to record when a raster occurs and associate the raster parameters with a Picture.
2) A new class, "traced_picture", has been added to asynchronously record base64 encoded Pictures. This has been hooked into locations where a new Picture is ready (after Picture::record and Picture::cloneForDrawing).
This is the first patch of several to add picture profiling to about:tracing.
BUG=240465
Review URL: https://chromiumcodereview.appspot.com/15095013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199964 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/debug')
-rw-r--r-- | cc/debug/traced_picture.cc | 36 | ||||
-rw-r--r-- | cc/debug/traced_picture.h | 35 |
2 files changed, 71 insertions, 0 deletions
diff --git a/cc/debug/traced_picture.cc b/cc/debug/traced_picture.cc new file mode 100644 index 0000000..756470a --- /dev/null +++ b/cc/debug/traced_picture.cc @@ -0,0 +1,36 @@ +// Copyright (c) 2013 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/debug/traced_picture.h" + +#include "base/json/json_writer.h" +#include "base/stringprintf.h" +#include "base/values.h" +#include "cc/debug/traced_value.h" + +namespace cc { + +TracedPicture::TracedPicture(scoped_refptr<Picture> picture) + : picture_(picture) { +} + +TracedPicture::~TracedPicture() { +} + +scoped_ptr<base::debug::ConvertableToTraceFormat> + TracedPicture::AsTraceablePicture(Picture* picture) { + TracedPicture* ptr = new TracedPicture(picture); + scoped_ptr<TracedPicture> result(ptr); + return result.PassAs<base::debug::ConvertableToTraceFormat>(); +} + +void TracedPicture::AppendAsTraceFormat(std::string* out) const { + std::string encoded_picture; + picture_->AsBase64String(&encoded_picture); + out->append("\""); + out->append(encoded_picture); + out->append("\""); +} + +} // namespace cc diff --git a/cc/debug/traced_picture.h b/cc/debug/traced_picture.h new file mode 100644 index 0000000..9137d8f --- /dev/null +++ b/cc/debug/traced_picture.h @@ -0,0 +1,35 @@ +// Copyright 2013 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 CC_DEBUG_TRACED_PICTURE_H_ +#define CC_DEBUG_TRACED_PICTURE_H_ + +#include <string> + +#include "base/debug/trace_event.h" +#include "base/memory/scoped_ptr.h" +#include "cc/resources/picture.h" + +namespace cc { + +class TracedPicture : public base::debug::ConvertableToTraceFormat { + public: + explicit TracedPicture(scoped_refptr<Picture>); + + virtual ~TracedPicture(); + + static scoped_ptr<base::debug::ConvertableToTraceFormat> + AsTraceablePicture(Picture* picture); + + virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; + + private: + scoped_refptr<Picture> picture_; + + DISALLOW_COPY_AND_ASSIGN(TracedPicture); +}; + +} // namespace cc + +#endif // CC_DEBUG_TRACED_PICTURE_H_ |