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

Side by Side Diff: chrome/renderer/chrome_render_frame_observer.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 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 "chrome/renderer/chrome_render_frame_observer.h" 5 #include "chrome/renderer/chrome_render_frame_observer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 thumbnail.readPixels(info, bitmap.getPixels(), bitmap.rowBytes(), 0, 0); 211 thumbnail.readPixels(info, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
212 } 212 }
213 } 213 }
214 214
215 std::vector<uint8_t> thumbnail_data; 215 std::vector<uint8_t> thumbnail_data;
216 if (bitmap.getPixels()) { 216 if (bitmap.getPixels()) {
217 const int kDefaultQuality = 90; 217 const int kDefaultQuality = 90;
218 std::vector<unsigned char> data; 218 std::vector<unsigned char> data;
219 if (gfx::JPEGCodec::Encode( 219 if (gfx::JPEGCodec::Encode(
220 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)), 220 reinterpret_cast<unsigned char*>(bitmap.getAddr32(0, 0)),
221 gfx::JPEGCodec::FORMAT_SkBitmap, bitmap.width(), bitmap.height(), 221 kN32_SkColorType, bitmap.width(), bitmap.height(),
222 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) { 222 static_cast<int>(bitmap.rowBytes()), kDefaultQuality, &data)) {
223 thumbnail_data.swap(data); 223 thumbnail_data.swap(data);
224 } 224 }
225 } 225 }
226 226
227 callback.Run(thumbnail_data, original_size); 227 callback.Run(thumbnail_data, original_size);
228 } 228 }
229 229
230 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() { 230 void ChromeRenderFrameObserver::OnPrintNodeUnderContextMenu() {
231 #if BUILDFLAG(ENABLE_PRINTING) 231 #if BUILDFLAG(ENABLE_PRINTING)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 const service_manager::BindSourceInfo& source_info, 365 const service_manager::BindSourceInfo& source_info,
366 chrome::mojom::ImageContextMenuRendererRequest request) { 366 chrome::mojom::ImageContextMenuRendererRequest request) {
367 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request)); 367 image_context_menu_renderer_bindings_.AddBinding(this, std::move(request));
368 } 368 }
369 369
370 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest( 370 void ChromeRenderFrameObserver::OnThumbnailCapturerRequest(
371 const service_manager::BindSourceInfo& source_info, 371 const service_manager::BindSourceInfo& source_info,
372 chrome::mojom::ThumbnailCapturerRequest request) { 372 chrome::mojom::ThumbnailCapturerRequest request) {
373 thumbnail_capturer_bindings_.AddBinding(this, std::move(request)); 373 thumbnail_capturer_bindings_.AddBinding(this, std::move(request));
374 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698