Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: content/browser/devtools/devtools_frame_trace_recorder.cc

Issue 2895953003: Use SkJpegEncoder in gfx jpeg_codec (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
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 bool encoded = gfx::JPEGCodec::Encode( 43 bool encoded = gfx::JPEGCodec::Encode(
44 reinterpret_cast<unsigned char*>(frame_.getAddr32(0, 0)), 44 reinterpret_cast<unsigned char*>(frame_.getAddr32(0, 0)),
45 gfx::JPEGCodec::FORMAT_SkBitmap, 45 kN32_SkColorType, frame_.width(), frame_.height(),
46 frame_.width(), frame_.height(),
47 frame_.width() * frame_.bytesPerPixel(), 80, &data); 46 frame_.width() * frame_.bytesPerPixel(), 80, &data);
48 if (encoded) { 47 if (encoded) {
49 std::string encoded_data; 48 std::string encoded_data;
50 base::Base64Encode( 49 base::Base64Encode(
51 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()), 50 base::StringPiece(reinterpret_cast<char*>(&data[0]), data.size()),
52 &encoded_data); 51 &encoded_data);
53 out->append(encoded_data); 52 out->append(encoded_data);
54 } 53 }
55 } 54 }
56 out->append("\""); 55 out->append("\"");
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 137
139 bool is_new_trace; 138 bool is_new_trace;
140 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); 139 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
141 if (!is_new_trace && last_metadata_) 140 if (!is_new_trace && last_metadata_)
142 CaptureFrame(host, *last_metadata_); 141 CaptureFrame(host, *last_metadata_);
143 last_metadata_.reset(new cc::CompositorFrameMetadata); 142 last_metadata_.reset(new cc::CompositorFrameMetadata);
144 *last_metadata_ = frame_metadata.Clone(); 143 *last_metadata_ = frame_metadata.Clone();
145 } 144 }
146 145
147 } // namespace content 146 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698