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

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

Issue 11418217: Add skia::RefPtr class to wrap ref counted classes from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop TNoRef Created 8 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 811 }
812 } 812 }
813 813
814 bool ChromeRenderViewObserver::CaptureSnapshot(WebView* view, 814 bool ChromeRenderViewObserver::CaptureSnapshot(WebView* view,
815 SkBitmap* snapshot) { 815 SkBitmap* snapshot) {
816 base::TimeTicks beginning_time = base::TimeTicks::Now(); 816 base::TimeTicks beginning_time = base::TimeTicks::Now();
817 817
818 view->layout(); 818 view->layout();
819 const WebSize& size = view->size(); 819 const WebSize& size = view->size();
820 820
821 SkCanvas* canvas = skia::CreatePlatformCanvas(size.width, size.height, true, 821 skia::RefPtr<SkCanvas> canvas = skia::CreatePlatformCanvas(
822 NULL, skia::RETURN_NULL_ON_FAILURE); 822 size.width, size.height, true, NULL, skia::RETURN_NULL_ON_FAILURE);
823 if (!canvas) 823 if (!canvas)
824 return false; 824 return false;
825 825
826 SkAutoUnref au(canvas); 826 view->paint(webkit_glue::ToWebCanvas(canvas.get()),
827 view->paint(webkit_glue::ToWebCanvas(canvas),
828 WebRect(0, 0, size.width, size.height)); 827 WebRect(0, 0, size.width, size.height));
829 // TODO: Add a way to snapshot the whole page, not just the currently 828 // TODO: Add a way to snapshot the whole page, not just the currently
830 // visible part. 829 // visible part.
831 830
832 SkDevice* device = skia::GetTopDevice(*canvas); 831 SkDevice* device = skia::GetTopDevice(*canvas);
833 832
834 const SkBitmap& bitmap = device->accessBitmap(false); 833 const SkBitmap& bitmap = device->accessBitmap(false);
835 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)) 834 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config))
836 return false; 835 return false;
837 836
838 HISTOGRAM_TIMES("Renderer4.Snapshot", 837 HISTOGRAM_TIMES("Renderer4.Snapshot",
839 base::TimeTicks::Now() - beginning_time); 838 base::TimeTicks::Now() - beginning_time);
840 return true; 839 return true;
841 } 840 }
842 841
843 ExternalHostBindings* ChromeRenderViewObserver::GetExternalHostBindings() { 842 ExternalHostBindings* ChromeRenderViewObserver::GetExternalHostBindings() {
844 if (!external_host_bindings_.get()) { 843 if (!external_host_bindings_.get()) {
845 external_host_bindings_.reset(new ExternalHostBindings( 844 external_host_bindings_.reset(new ExternalHostBindings(
846 render_view(), routing_id())); 845 render_view(), routing_id()));
847 } 846 }
848 return external_host_bindings_.get(); 847 return external_host_bindings_.get();
849 } 848 }
850 849
851 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) { 850 bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) {
852 return (strict_security_hosts_.find(host) != strict_security_hosts_.end()); 851 return (strict_security_hosts_.find(host) != strict_security_hosts_.end());
853 } 852 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698