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

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

Issue 10996037: Do not convert from RectF to Rect by flooring. (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 "content/browser/renderer_host/backing_store_aura.h" 5 #include "content/browser/renderer_host/backing_store_aura.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 TransportDIB::Id bitmap, 80 TransportDIB::Id bitmap,
81 const gfx::Rect& bitmap_rect, 81 const gfx::Rect& bitmap_rect,
82 const std::vector<gfx::Rect>& copy_rects, 82 const std::vector<gfx::Rect>& copy_rects,
83 float scale_factor, 83 float scale_factor,
84 const base::Closure& completion_callback, 84 const base::Closure& completion_callback,
85 bool* scheduled_completion_callback) { 85 bool* scheduled_completion_callback) {
86 *scheduled_completion_callback = false; 86 *scheduled_completion_callback = false;
87 if (bitmap_rect.IsEmpty()) 87 if (bitmap_rect.IsEmpty())
88 return; 88 return;
89 89
90 gfx::Rect pixel_bitmap_rect = bitmap_rect.Scale(scale_factor); 90 gfx::Rect pixel_bitmap_rect = bitmap_rect.ScaleUnsafe(scale_factor);
91 91
92 const int width = pixel_bitmap_rect.width(); 92 const int width = pixel_bitmap_rect.width();
93 const int height = pixel_bitmap_rect.height(); 93 const int height = pixel_bitmap_rect.height();
94 94
95 if (width <= 0 || width > kMaxVideoLayerSize || 95 if (width <= 0 || width > kMaxVideoLayerSize ||
96 height <= 0 || height > kMaxVideoLayerSize) 96 height <= 0 || height > kMaxVideoLayerSize)
97 return; 97 return;
98 98
99 TransportDIB* dib = process->GetTransportDIB(bitmap); 99 TransportDIB* dib = process->GetTransportDIB(bitmap);
100 if (!dib) 100 if (!dib)
101 return; 101 return;
102 102
103 SkPaint copy_paint; 103 SkPaint copy_paint;
104 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode); 104 copy_paint.setXfermodeMode(SkXfermode::kSrc_Mode);
105 105
106 SkBitmap sk_bitmap; 106 SkBitmap sk_bitmap;
107 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 107 sk_bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
108 sk_bitmap.setPixels(dib->memory()); 108 sk_bitmap.setPixels(dib->memory());
109 for (size_t i = 0; i < copy_rects.size(); i++) { 109 for (size_t i = 0; i < copy_rects.size(); i++) {
110 const gfx::Rect pixel_copy_rect = copy_rects[i].Scale(scale_factor); 110 const gfx::Rect pixel_copy_rect = copy_rects[i].ScaleUnsafe(scale_factor);
111 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x(); 111 int x = pixel_copy_rect.x() - pixel_bitmap_rect.x();
112 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y(); 112 int y = pixel_copy_rect.y() - pixel_bitmap_rect.y();
113 SkIRect srcrect = SkIRect::MakeXYWH(x, y, 113 SkIRect srcrect = SkIRect::MakeXYWH(x, y,
114 pixel_copy_rect.width(), 114 pixel_copy_rect.width(),
115 pixel_copy_rect.height()); 115 pixel_copy_rect.height());
116 116
117 const gfx::Rect pixel_copy_dst_rect = 117 const gfx::Rect pixel_copy_dst_rect =
118 copy_rects[i].Scale(device_scale_factor_); 118 copy_rects[i].ScaleUnsafe(device_scale_factor_);
119 SkRect dstrect = SkRect::MakeXYWH( 119 SkRect dstrect = SkRect::MakeXYWH(
120 SkIntToScalar(pixel_copy_dst_rect.x()), 120 SkIntToScalar(pixel_copy_dst_rect.x()),
121 SkIntToScalar(pixel_copy_dst_rect.y()), 121 SkIntToScalar(pixel_copy_dst_rect.y()),
122 SkIntToScalar(pixel_copy_dst_rect.width()), 122 SkIntToScalar(pixel_copy_dst_rect.width()),
123 SkIntToScalar(pixel_copy_dst_rect.height())); 123 SkIntToScalar(pixel_copy_dst_rect.height()));
124 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect, &copy_paint); 124 canvas_.get()->drawBitmapRect(sk_bitmap, &srcrect, dstrect, &copy_paint);
125 } 125 }
126 } 126 }
127 127
128 void BackingStoreAura::ScrollBackingStore(int dx, int dy, 128 void BackingStoreAura::ScrollBackingStore(int dx, int dy,
129 const gfx::Rect& clip_rect, 129 const gfx::Rect& clip_rect,
130 const gfx::Size& view_size) { 130 const gfx::Size& view_size) {
131 gfx::Rect pixel_rect = clip_rect.Scale(device_scale_factor_); 131 gfx::Rect pixel_rect = clip_rect.ScaleUnsafe(device_scale_factor_);
132 int pixel_dx = dx * device_scale_factor_; 132 int pixel_dx = dx * device_scale_factor_;
133 int pixel_dy = dy * device_scale_factor_; 133 int pixel_dy = dy * device_scale_factor_;
134 134
135 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx); 135 int x = std::min(pixel_rect.x(), pixel_rect.x() - pixel_dx);
136 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy); 136 int y = std::min(pixel_rect.y(), pixel_rect.y() - pixel_dy);
137 int w = pixel_rect.width() + abs(pixel_dx); 137 int w = pixel_rect.width() + abs(pixel_dx);
138 int h = pixel_rect.height() + abs(pixel_dy); 138 int h = pixel_rect.height() + abs(pixel_dy);
139 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h); 139 SkIRect rect = SkIRect::MakeXYWH(x, y, w, h);
140 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy); 140 bitmap_.scrollRect(&rect, pixel_dx, pixel_dy);
141 } 141 }
(...skipping 10 matching lines...) Expand all
152 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true); 152 SkBitmap bitmap = skia::GetTopDevice(*output)->accessBitmap(true);
153 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height); 153 SkIRect skrect = SkIRect::MakeXYWH(rect.x(), rect.y(), width, height);
154 SkBitmap b; 154 SkBitmap b;
155 if (!canvas_->readPixels(skrect, &b)) 155 if (!canvas_->readPixels(skrect, &b))
156 return false; 156 return false;
157 output->writePixels(b, rect.x(), rect.y()); 157 output->writePixels(b, rect.x(), rect.y());
158 return true; 158 return true;
159 } 159 }
160 160
161 } // namespace content 161 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/browser_plugin/browser_plugin_backing_store.cc » ('j') | ui/gfx/rect.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698