OLD | NEW |
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 "ui/gfx/blit.h" | 5 #include "ui/gfx/blit.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "skia/ext/platform_canvas.h" | 9 #include "skia/ext/platform_canvas.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 #endif // defined(OS_WIN) | 145 #endif // defined(OS_WIN) |
146 // For non-windows, always do scrolling in software. | 146 // For non-windows, always do scrolling in software. |
147 // Cairo has no nice scroll function so we do our own. On Mac it's possible to | 147 // Cairo has no nice scroll function so we do our own. On Mac it's possible to |
148 // use platform scroll code, but it's complex so we just use the same path | 148 // use platform scroll code, but it's complex so we just use the same path |
149 // here. Either way it will be software-only, so it shouldn't matter much. | 149 // here. Either way it will be software-only, so it shouldn't matter much. |
150 SkBitmap& bitmap = const_cast<SkBitmap&>( | 150 SkBitmap& bitmap = const_cast<SkBitmap&>( |
151 skia::GetTopDevice(*canvas)->accessBitmap(true)); | 151 skia::GetTopDevice(*canvas)->accessBitmap(true)); |
152 SkAutoLockPixels lock(bitmap); | 152 SkAutoLockPixels lock(bitmap); |
153 | 153 |
154 // We expect all coords to be inside the canvas, so clip here. | 154 // We expect all coords to be inside the canvas, so clip here. |
155 gfx::Rect clip = in_clip; | 155 gfx::Rect clip = gfx::IntersectRects( |
156 clip.Intersect(gfx::Rect(0, 0, bitmap.width(), bitmap.height())); | 156 in_clip, gfx::Rect(0, 0, bitmap.width(), bitmap.height())); |
157 | 157 |
158 // Compute the set of pixels we'll actually end up painting. | 158 // Compute the set of pixels we'll actually end up painting. |
159 gfx::Rect dest_rect = clip; | 159 gfx::Rect dest_rect = clip; |
160 dest_rect.Offset(amount); | 160 dest_rect.Offset(amount); |
161 dest_rect.Intersect(clip); | 161 dest_rect.Intersect(clip); |
162 if (dest_rect.size() == gfx::Size()) | 162 if (dest_rect.size() == gfx::Size()) |
163 return; // Nothing to do. | 163 return; // Nothing to do. |
164 | 164 |
165 // Compute the source pixels that will map to the dest_rect | 165 // Compute the source pixels that will map to the dest_rect |
166 gfx::Rect src_rect = dest_rect; | 166 gfx::Rect src_rect = dest_rect; |
(...skipping 20 matching lines...) Expand all Loading... |
187 // Fortunately, memmove already handles this for us. | 187 // Fortunately, memmove already handles this for us. |
188 for (int y = 0; y < dest_rect.height(); y++) { | 188 for (int y = 0; y < dest_rect.height(); y++) { |
189 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), | 189 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), |
190 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), | 190 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), |
191 row_bytes); | 191 row_bytes); |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 } // namespace gfx | 196 } // namespace gfx |
OLD | NEW |