| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/devtools/devtools_frame_trace_recorder.h" | 5 #include "content/browser/devtools/devtools_frame_trace_recorder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 class TraceableDevToolsScreenshot | 34 class TraceableDevToolsScreenshot |
| 35 : public base::trace_event::ConvertableToTraceFormat { | 35 : public base::trace_event::ConvertableToTraceFormat { |
| 36 public: | 36 public: |
| 37 TraceableDevToolsScreenshot(const SkBitmap& bitmap) : frame_(bitmap) {} | 37 TraceableDevToolsScreenshot(const SkBitmap& bitmap) : frame_(bitmap) {} |
| 38 | 38 |
| 39 void AppendAsTraceFormat(std::string* out) const override { | 39 void AppendAsTraceFormat(std::string* out) const override { |
| 40 out->append("\""); | 40 out->append("\""); |
| 41 if (!frame_.drawsNothing()) { | 41 if (!frame_.drawsNothing()) { |
| 42 std::vector<unsigned char> data; | 42 std::vector<unsigned char> data; |
| 43 SkAutoLockPixels lock_image(frame_); | |
| 44 bool encoded = gfx::JPEGCodec::Encode( | 43 bool encoded = gfx::JPEGCodec::Encode( |
| 45 reinterpret_cast<unsigned char*>(frame_.getAddr32(0, 0)), | 44 reinterpret_cast<unsigned char*>(frame_.getAddr32(0, 0)), |
| 46 gfx::JPEGCodec::FORMAT_SkBitmap, | 45 gfx::JPEGCodec::FORMAT_SkBitmap, |
| 47 frame_.width(), frame_.height(), | 46 frame_.width(), frame_.height(), |
| 48 frame_.width() * frame_.bytesPerPixel(), 80, &data); | 47 frame_.width() * frame_.bytesPerPixel(), 80, &data); |
| 49 if (encoded) { | 48 if (encoded) { |
| 50 std::string encoded_data; | 49 std::string encoded_data; |
| 51 base::Base64Encode( | 50 base::Base64Encode( |
| 52 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), | 51 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), |
| 53 &encoded_data); | 52 &encoded_data); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 138 |
| 140 bool is_new_trace; | 139 bool is_new_trace; |
| 141 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 140 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
| 142 if (!is_new_trace && last_metadata_) | 141 if (!is_new_trace && last_metadata_) |
| 143 CaptureFrame(host, *last_metadata_); | 142 CaptureFrame(host, *last_metadata_); |
| 144 last_metadata_.reset(new cc::CompositorFrameMetadata); | 143 last_metadata_.reset(new cc::CompositorFrameMetadata); |
| 145 *last_metadata_ = frame_metadata.Clone(); | 144 *last_metadata_ = frame_metadata.Clone(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 } // namespace content | 147 } // namespace content |
| OLD | NEW |