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

Side by Side Diff: content/browser/renderer_host/backing_store_skia.cc

Issue 10540144: Tag TransportDIBs with the device scale factor they expect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 6 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 "content/browser/renderer_host/backing_store_skia.h" 5 #include "content/browser/renderer_host/backing_store_skia.h"
6 6
7 #include "content/browser/renderer_host/dip_util.h" 7 #include "content/browser/renderer_host/dip_util.h"
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // NOTE: The computation may be different when the canvas is a subrectangle of 44 // NOTE: The computation may be different when the canvas is a subrectangle of
45 // a larger bitmap. 45 // a larger bitmap.
46 return size().Scale(device_scale_factor_).GetArea() * 4; 46 return size().Scale(device_scale_factor_).GetArea() * 4;
47 } 47 }
48 48
49 void BackingStoreSkia::PaintToBackingStore( 49 void BackingStoreSkia::PaintToBackingStore(
50 content::RenderProcessHost* process, 50 content::RenderProcessHost* process,
51 TransportDIB::Id bitmap, 51 TransportDIB::Id bitmap,
52 const gfx::Rect& bitmap_rect, 52 const gfx::Rect& bitmap_rect,
53 const std::vector<gfx::Rect>& copy_rects, 53 const std::vector<gfx::Rect>& copy_rects,
54 float scale_factor,
54 const base::Closure& completion_callback, 55 const base::Closure& completion_callback,
55 bool* scheduled_completion_callback) { 56 bool* scheduled_completion_callback) {
56 *scheduled_completion_callback = false; 57 *scheduled_completion_callback = false;
57 if (bitmap_rect.IsEmpty()) 58 if (bitmap_rect.IsEmpty())
58 return; 59 return;
59 60
60 gfx::Rect pixel_rect = bitmap_rect.Scale(device_scale_factor_); 61 gfx::Rect pixel_rect = bitmap_rect.Scale(device_scale_factor_);
61 62
62 const int width = pixel_rect.width(); 63 const int width = pixel_rect.width();
63 const int height = pixel_rect.height(); 64 const int height = pixel_rect.height();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return false; 113 return false;
113 114
114 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); 115 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
115 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); 116 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height);
116 SkBitmap b; 117 SkBitmap b;
117 if (!canvas_->readPixels(skrect, &b)) 118 if (!canvas_->readPixels(skrect, &b))
118 return false; 119 return false;
119 output->writePixels(b, rect.x(), rect.y()); 120 output->writePixels(b, rect.x(), rect.y());
120 return true; 121 return true;
121 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698