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

Side by Side Diff: extensions/browser/api/web_contents_capture_client.cc

Issue 1863953002: <webview>: Fix missing transparency in captureVisibleRegion(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 case api::extension_types::IMAGE_FORMAT_JPEG: 113 case api::extension_types::IMAGE_FORMAT_JPEG:
114 encoded = gfx::JPEGCodec::Encode( 114 encoded = gfx::JPEGCodec::Encode(
115 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), 115 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
116 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), 116 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(),
117 static_cast<int>(bitmap.rowBytes()), image_quality_, &data); 117 static_cast<int>(bitmap.rowBytes()), image_quality_, &data);
118 mime_type = kMimeTypeJpeg; 118 mime_type = kMimeTypeJpeg;
119 break; 119 break;
120 case api::extension_types::IMAGE_FORMAT_PNG: 120 case api::extension_types::IMAGE_FORMAT_PNG:
121 encoded = 121 encoded =
122 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, 122 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap,
123 true, // Discard transparency. 123 /* Don't discard transparency */
wjmaclean 2016/04/06 12:39:20 This comment could be re-worded, something like "D
avallee 2016/04/06 14:12:27 Done.
124 &data); 124 !ContentsHasTransparency(), &data);
125 mime_type = kMimeTypePng; 125 mime_type = kMimeTypePng;
126 break; 126 break;
127 default: 127 default:
128 NOTREACHED() << "Invalid image format."; 128 NOTREACHED() << "Invalid image format.";
129 } 129 }
130 130
131 if (!encoded) 131 if (!encoded)
132 return false; 132 return false;
133 133
134 base::StringPiece stream_as_string(reinterpret_cast<const char*>(data.data()), 134 base::StringPiece stream_as_string(reinterpret_cast<const char*>(data.data()),
135 data.size()); 135 data.size());
136 136
137 base::Base64Encode(stream_as_string, base64_result); 137 base::Base64Encode(stream_as_string, base64_result);
138 base64_result->insert( 138 base64_result->insert(
139 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 139 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
140 140
141 return true; 141 return true;
142 } 142 }
143 143
144 } // namespace extensions 144 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698