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

Side by Side Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/icon_messages.h" 12 #include "chrome/common/icon_messages.h"
13 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
14 #include "chrome/common/thumbnail_score.h" 14 #include "chrome/common/thumbnail_score.h"
15 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
16 #include "chrome/renderer/about_handler.h" 16 #include "chrome/renderer/about_handler.h"
17 #include "chrome/renderer/content_settings_observer.h" 17 #include "chrome/renderer/content_settings_observer.h"
18 #include "chrome/renderer/automation/dom_automation_controller.h" 18 #include "chrome/renderer/automation/dom_automation_controller.h"
19 #include "chrome/renderer/extensions/extension_dispatcher.h" 19 #include "chrome/renderer/extensions/extension_dispatcher.h"
20 #include "chrome/renderer/external_host_bindings.h" 20 #include "chrome/renderer/external_host_bindings.h"
21 #include "chrome/renderer/prerender/prerender_helper.h" 21 #include "chrome/renderer/prerender/prerender_helper.h"
22 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 22 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
23 #include "chrome/renderer/translate_helper.h" 23 #include "chrome/renderer/translate_helper.h"
24 #include "content/common/bindings_policy.h" 24 #include "content/common/bindings_policy.h"
25 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
26 #include "content/renderer/content_renderer_client.h" 26 #include "content/renderer/content_renderer_client.h"
27 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
28 #include "net/base/data_url.h" 28 #include "net/base/data_url.h"
29 #include "skia/ext/bitmap_platform_device.h"
30 #include "skia/ext/image_operations.h" 29 #include "skia/ext/image_operations.h"
31 #include "skia/ext/platform_canvas.h" 30 #include "skia/ext/platform_canvas.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 SkBitmap* thumbnail, 587 SkBitmap* thumbnail,
589 ThumbnailScore* score) { 588 ThumbnailScore* score) {
590 base::TimeTicks beginning_time = base::TimeTicks::Now(); 589 base::TimeTicks beginning_time = base::TimeTicks::Now();
591 590
592 skia::PlatformCanvas canvas; 591 skia::PlatformCanvas canvas;
593 592
594 // Paint |view| into |canvas|. 593 // Paint |view| into |canvas|.
595 if (!PaintViewIntoCanvas(view, canvas)) 594 if (!PaintViewIntoCanvas(view, canvas))
596 return false; 595 return false;
597 596
598 skia::BitmapPlatformDevice& device = 597 SkDevice& device = canvas.getTopDevice();
599 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
600 598
601 const SkBitmap& src_bmp = device.accessBitmap(false); 599 const SkBitmap& src_bmp = device.accessBitmap(false);
602 600
603 SkRect dest_rect = { 0, 0, SkIntToScalar(w), SkIntToScalar(h) }; 601 SkRect dest_rect = { 0, 0, SkIntToScalar(w), SkIntToScalar(h) };
604 float dest_aspect = dest_rect.width() / dest_rect.height(); 602 float dest_aspect = dest_rect.width() / dest_rect.height();
605 603
606 // Get the src rect so that we can preserve the aspect ratio while filling 604 // Get the src rect so that we can preserve the aspect ratio while filling
607 // the destination. 605 // the destination.
608 SkIRect src_rect; 606 SkIRect src_rect;
609 if (src_bmp.width() < dest_rect.width() || 607 if (src_bmp.width() < dest_rect.width() ||
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 650 }
653 651
654 bool ChromeRenderViewObserver::CaptureSnapshot(WebView* view, 652 bool ChromeRenderViewObserver::CaptureSnapshot(WebView* view,
655 SkBitmap* snapshot) { 653 SkBitmap* snapshot) {
656 base::TimeTicks beginning_time = base::TimeTicks::Now(); 654 base::TimeTicks beginning_time = base::TimeTicks::Now();
657 655
658 skia::PlatformCanvas canvas; 656 skia::PlatformCanvas canvas;
659 if (!PaintViewIntoCanvas(view, canvas)) 657 if (!PaintViewIntoCanvas(view, canvas))
660 return false; 658 return false;
661 659
662 skia::BitmapPlatformDevice& device = 660 SkDevice& device = canvas.getTopDevice();
663 static_cast<skia::BitmapPlatformDevice&>(canvas.getTopPlatformDevice());
664 661
665 const SkBitmap& bitmap = device.accessBitmap(false); 662 const SkBitmap& bitmap = device.accessBitmap(false);
666 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)) 663 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
667 return false; 664 return false;
668 665
669 HISTOGRAM_TIMES("Renderer4.Snapshot", 666 HISTOGRAM_TIMES("Renderer4.Snapshot",
670 base::TimeTicks::Now() - beginning_time); 667 base::TimeTicks::Now() - beginning_time);
671 return true; 668 return true;
672 } 669 }
673 670
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { 726 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) {
730 // Decode the favicon using WebKit's image decoder. 727 // Decode the favicon using WebKit's image decoder.
731 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); 728 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize));
732 const unsigned char* src_data = 729 const unsigned char* src_data =
733 reinterpret_cast<const unsigned char*>(&data[0]); 730 reinterpret_cast<const unsigned char*>(&data[0]);
734 731
735 return decoder.Decode(src_data, data.size()); 732 return decoder.Decode(src_data, data.size());
736 } 733 }
737 return SkBitmap(); 734 return SkBitmap();
738 } 735 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698