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

Side by Side Diff: chrome/browser/prerender/prerender_tab_helper.cc

Issue 11031055: Introduce PlatformBitmap, which is a minimal helper class that wraps an SkBitmap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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) 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/browser/prerender/prerender_tab_helper.h" 5 #include "chrome/browser/prerender/prerender_tab_helper.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/prerender/prerender_histograms.h" 10 #include "chrome/browser/prerender/prerender_histograms.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 if (bitmap_type == BITMAP_ON_LOAD && bitmap_web_contents_ != web_contents) 50 if (bitmap_type == BITMAP_ON_LOAD && bitmap_web_contents_ != web_contents)
51 return; 51 return;
52 52
53 if (!web_contents || !web_contents->GetView() || 53 if (!web_contents || !web_contents->GetView() ||
54 !web_contents->GetRenderViewHost()) { 54 !web_contents->GetRenderViewHost()) {
55 return; 55 return;
56 } 56 }
57 57
58 skia::PlatformCanvas* temp_canvas = new skia::PlatformCanvas; 58 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap;
59 web_contents->GetRenderViewHost()->CopyFromBackingStore( 59 web_contents->GetRenderViewHost()->CopyFromBackingStore(
60 gfx::Rect(), 60 gfx::Rect(),
61 gfx::Size(), 61 gfx::Size(),
62 base::Bind(&PrerenderTabHelper::PixelStats::HandleBitmapResult, 62 base::Bind(&PrerenderTabHelper::PixelStats::HandleBitmapResult,
63 weak_factory_.GetWeakPtr(), 63 weak_factory_.GetWeakPtr(),
64 bitmap_type, 64 bitmap_type,
65 web_contents, 65 web_contents,
66 base::Owned(temp_canvas)), 66 base::Owned(temp_bitmap)),
67 temp_canvas); 67 temp_bitmap);
68 } 68 }
69 69
70 private: 70 private:
71 void HandleBitmapResult(BitmapType bitmap_type, 71 void HandleBitmapResult(BitmapType bitmap_type,
72 WebContents* web_contents, 72 WebContents* web_contents,
73 skia::PlatformCanvas* temp_canvas, 73 skia::PlatformBitmap* temp_bitmap,
74 bool succeeded) { 74 bool succeeded) {
75 scoped_ptr<SkBitmap> bitmap; 75 scoped_ptr<SkBitmap> bitmap;
76 if (succeeded) { 76 if (succeeded) {
77 const SkBitmap& canvas_bitmap = 77 const SkBitmap& canvas_bitmap = temp_bitmap->GetBitmap();
78 skia::GetTopDevice(*temp_canvas)->accessBitmap(false);
79 bitmap.reset(new SkBitmap()); 78 bitmap.reset(new SkBitmap());
80 canvas_bitmap.copyTo(bitmap.get(), SkBitmap::kARGB_8888_Config); 79 canvas_bitmap.copyTo(bitmap.get(), SkBitmap::kARGB_8888_Config);
81 } 80 }
82 81
83 if (bitmap_web_contents_ != web_contents) 82 if (bitmap_web_contents_ != web_contents)
84 return; 83 return;
85 84
86 if (bitmap_type == BITMAP_SWAP_IN) 85 if (bitmap_type == BITMAP_SWAP_IN)
87 bitmap_.swap(bitmap); 86 bitmap_.swap(bitmap);
88 87
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // If we have not finished loading yet, record the actual load start, and 244 // If we have not finished loading yet, record the actual load start, and
246 // rebase the start time to now. 245 // rebase the start time to now.
247 actual_load_start_ = pplt_load_start_; 246 actual_load_start_ = pplt_load_start_;
248 pplt_load_start_ = base::TimeTicks::Now(); 247 pplt_load_start_ = base::TimeTicks::Now();
249 if (pixel_stats_.get()) 248 if (pixel_stats_.get())
250 pixel_stats_->GetBitmap(PixelStats::BITMAP_SWAP_IN, web_contents()); 249 pixel_stats_->GetBitmap(PixelStats::BITMAP_SWAP_IN, web_contents());
251 } 250 }
252 } 251 }
253 252
254 } // namespace prerender 253 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.cc ('k') | chrome/browser/thumbnails/thumbnail_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698