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

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

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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 22 matching lines...) Expand all
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
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
OLDNEW
« no previous file with comments | « content/browser/compositor/surface_utils.cc ('k') | content/browser/devtools/protocol/devtools_protocol_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698