Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 | 64 |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 void ScrollCanvas(SkCanvas* canvas, | 70 void ScrollCanvas(SkCanvas* canvas, |
| 71 const gfx::Rect& in_clip, | 71 const gfx::Rect& in_clip, |
| 72 const gfx::Vector2d& offset) { | 72 const gfx::Vector2d& offset) { |
| 73 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. | 73 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. |
| 74 #if defined(OS_WIN) | |
| 75 // If we have a PlatformCanvas, we should use ScrollDC. Otherwise, fall | |
| 76 // through to the software implementation. | |
| 77 if (skia::SupportsPlatformPaint(canvas)) { | |
| 78 skia::ScopedPlatformPaint scoped_platform_paint(canvas); | |
| 79 HDC hdc = scoped_platform_paint.GetNativeDrawingContext(); | |
| 80 | 74 |
| 81 RECT damaged_rect; | 75 SkPixmap pixmap; |
| 82 RECT r = in_clip.ToRECT(); | 76 bool success = skia::GetWritablePixels(canvas, &pixmap); |
| 83 ScrollDC(hdc, offset.x(), offset.y(), NULL, &r, NULL, &damaged_rect); | 77 DCHECK(success); |
|
danakj
2016/12/21 15:56:11
Either DCHECK or do the if (!) return, but not bot
reed1
2016/12/21 15:58:30
We never checked before, so I'd guess it never hap
danakj
2016/12/21 16:03:29
Ya that shouldn't be done, our style guide is expl
| |
| 78 if (!success) | |
| 84 return; | 79 return; |
| 85 } | |
| 86 #endif // defined(OS_WIN) | |
| 87 // For non-windows, always do scrolling in software. | |
| 88 // Cairo has no nice scroll function so we do our own. On Mac it's possible to | |
| 89 // use platform scroll code, but it's complex so we just use the same path | |
| 90 // here. Either way it will be software-only, so it shouldn't matter much. | |
| 91 SkPixmap pixmap; | |
| 92 skia::GetWritablePixels(canvas, &pixmap); | |
| 93 | 80 |
| 94 // We expect all coords to be inside the canvas, so clip here. | 81 // We expect all coords to be inside the canvas, so clip here. |
| 95 gfx::Rect clip = gfx::IntersectRects( | 82 gfx::Rect clip = gfx::IntersectRects( |
| 96 in_clip, gfx::Rect(0, 0, pixmap.width(), pixmap.height())); | 83 in_clip, gfx::Rect(0, 0, pixmap.width(), pixmap.height())); |
| 97 | 84 |
| 98 // Compute the set of pixels we'll actually end up painting. | 85 // Compute the set of pixels we'll actually end up painting. |
| 99 gfx::Rect dest_rect = gfx::IntersectRects(clip + offset, clip); | 86 gfx::Rect dest_rect = gfx::IntersectRects(clip + offset, clip); |
| 100 if (dest_rect.size().IsEmpty()) | 87 if (dest_rect.size().IsEmpty()) |
| 101 return; // Nothing to do. | 88 return; // Nothing to do. |
| 102 | 89 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 124 // Fortunately, memmove already handles this for us. | 111 // Fortunately, memmove already handles this for us. |
| 125 for (int y = 0; y < dest_rect.height(); y++) { | 112 for (int y = 0; y < dest_rect.height(); y++) { |
| 126 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y), | 113 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y), |
| 127 pixmap.addr32(src_rect.x(), src_rect.y() + y), | 114 pixmap.addr32(src_rect.x(), src_rect.y() + y), |
| 128 row_bytes); | 115 row_bytes); |
| 129 } | 116 } |
| 130 } | 117 } |
| 131 } | 118 } |
| 132 | 119 |
| 133 } // namespace gfx | 120 } // namespace gfx |
| OLD | NEW |