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

Side by Side Diff: extensions/browser/api/web_contents_capture_client.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
« no previous file with comments | « content/test/image_decoder_test.cc ('k') | media/blink/webmediaplayer_cast_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/api/web_contents_capture_client.h" 5 #include "extensions/browser/api/web_contents_capture_client.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 reason = "<unknown>"; 84 reason = "<unknown>";
85 } 85 }
86 OnCaptureFailure(FAILURE_REASON_UNKNOWN); 86 OnCaptureFailure(FAILURE_REASON_UNKNOWN);
87 } 87 }
88 88
89 // TODO(wjmaclean) can this be static? 89 // TODO(wjmaclean) can this be static?
90 bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap, 90 bool WebContentsCaptureClient::EncodeBitmap(const SkBitmap& bitmap,
91 std::string* base64_result) { 91 std::string* base64_result) {
92 DCHECK(base64_result); 92 DCHECK(base64_result);
93 std::vector<unsigned char> data; 93 std::vector<unsigned char> data;
94 SkAutoLockPixels screen_capture_lock(bitmap);
95 const bool should_discard_alpha = !ClientAllowsTransparency(); 94 const bool should_discard_alpha = !ClientAllowsTransparency();
96 bool encoded = false; 95 bool encoded = false;
97 std::string mime_type; 96 std::string mime_type;
98 switch (image_format_) { 97 switch (image_format_) {
99 case api::extension_types::IMAGE_FORMAT_JPEG: 98 case api::extension_types::IMAGE_FORMAT_JPEG:
100 encoded = gfx::JPEGCodec::Encode( 99 encoded = gfx::JPEGCodec::Encode(
101 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), 100 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
102 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), 101 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
103 static_cast<int>(bitmap.rowBytes()), image_quality_, &data); 102 static_cast<int>(bitmap.rowBytes()), image_quality_, &data);
104 mime_type = kMimeTypeJpeg; 103 mime_type = kMimeTypeJpeg;
(...skipping 14 matching lines...) Expand all
119 data.size()); 118 data.size());
120 119
121 base::Base64Encode(stream_as_string, base64_result); 120 base::Base64Encode(stream_as_string, base64_result);
122 base64_result->insert( 121 base64_result->insert(
123 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 122 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
124 123
125 return true; 124 return true;
126 } 125 }
127 126
128 } // namespace extensions 127 } // namespace extensions
OLDNEW
« no previous file with comments | « content/test/image_decoder_test.cc ('k') | media/blink/webmediaplayer_cast_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698