| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "skia/ext/platform_device.h" | 10 #include "skia/ext/platform_device.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 bool HasClipOrTransform(const skia::PlatformCanvas& canvas) { | 28 bool HasClipOrTransform(const skia::PlatformCanvas& canvas) { |
| 29 if (!canvas.getTotalMatrix().isIdentity()) | 29 if (!canvas.getTotalMatrix().isIdentity()) |
| 30 return true; | 30 return true; |
| 31 | 31 |
| 32 const SkRegion& clip_region = canvas.getTotalClip(); | 32 const SkRegion& clip_region = canvas.getTotalClip(); |
| 33 if (clip_region.isEmpty() || clip_region.isComplex()) | 33 if (clip_region.isEmpty() || clip_region.isComplex()) |
| 34 return true; | 34 return true; |
| 35 | 35 |
| 36 // Now we know the clip is a regular rectangle, make sure it covers the | 36 // Now we know the clip is a regular rectangle, make sure it covers the |
| 37 // entire canvas. | 37 // entire canvas. |
| 38 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); | 38 const SkBitmap& bitmap = canvas.getTopDevice().accessBitmap(false); |
| 39 const SkIRect& clip_bounds = clip_region.getBounds(); | 39 const SkIRect& clip_bounds = clip_region.getBounds(); |
| 40 if (clip_bounds.fLeft != 0 || clip_bounds.fTop != 0 || | 40 if (clip_bounds.fLeft != 0 || clip_bounds.fTop != 0 || |
| 41 clip_bounds.fRight != bitmap.width() || | 41 clip_bounds.fRight != bitmap.width() || |
| 42 clip_bounds.fBottom != bitmap.height()) | 42 clip_bounds.fBottom != bitmap.height()) |
| 43 return true; | 43 return true; |
| 44 | 44 |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 #elif defined(OS_POSIX) | 137 #elif defined(OS_POSIX) |
| 138 // Cairo has no nice scroll function so we do our own. On Mac it's possible to | 138 // Cairo has no nice scroll function so we do our own. On Mac it's possible to |
| 139 // use platform scroll code, but it's complex so we just use the same path | 139 // use platform scroll code, but it's complex so we just use the same path |
| 140 // here. Either way it will be software-only, so it shouldn't matter much. | 140 // here. Either way it will be software-only, so it shouldn't matter much. |
| 141 | 141 |
| 142 void ScrollCanvas(skia::PlatformCanvas* canvas, | 142 void ScrollCanvas(skia::PlatformCanvas* canvas, |
| 143 const gfx::Rect& in_clip, | 143 const gfx::Rect& in_clip, |
| 144 const gfx::Point& amount) { | 144 const gfx::Point& amount) { |
| 145 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. | 145 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. |
| 146 SkBitmap& bitmap = const_cast<SkBitmap&>( | 146 SkBitmap& bitmap = const_cast<SkBitmap&>( |
| 147 canvas->getTopPlatformDevice().accessBitmap(true)); | 147 canvas->getTopDevice().accessBitmap(true)); |
| 148 SkAutoLockPixels lock(bitmap); | 148 SkAutoLockPixels lock(bitmap); |
| 149 | 149 |
| 150 // We expect all coords to be inside the canvas, so clip here. | 150 // We expect all coords to be inside the canvas, so clip here. |
| 151 gfx::Rect clip = in_clip.Intersect( | 151 gfx::Rect clip = in_clip.Intersect( |
| 152 gfx::Rect(0, 0, bitmap.width(), bitmap.height())); | 152 gfx::Rect(0, 0, bitmap.width(), bitmap.height())); |
| 153 | 153 |
| 154 // Compute the set of pixels we'll actually end up painting. | 154 // Compute the set of pixels we'll actually end up painting. |
| 155 gfx::Rect dest_rect = clip; | 155 gfx::Rect dest_rect = clip; |
| 156 dest_rect.Offset(amount); | 156 dest_rect.Offset(amount); |
| 157 dest_rect = dest_rect.Intersect(clip); | 157 dest_rect = dest_rect.Intersect(clip); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 185 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), | 185 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), |
| 186 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), | 186 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), |
| 187 row_bytes); | 187 row_bytes); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 #endif | 192 #endif |
| 193 | 193 |
| 194 } // namespace gfx | 194 } // namespace gfx |
| OLD | NEW |