| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "base/mac/scoped_cftyperef.h" | 32 #include "base/mac/scoped_cftyperef.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 namespace gfx { | 35 namespace gfx { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // Returns true if the given canvas has any part of itself clipped out or | 39 // Returns true if the given canvas has any part of itself clipped out or |
| 40 // any non-identity tranform. | 40 // any non-identity tranform. |
| 41 bool HasClipOrTransform(SkCanvas& canvas) { | 41 bool HasClipOrTransform(CdlCanvas& canvas) { |
| 42 if (!canvas.getTotalMatrix().isIdentity()) | 42 if (!canvas.getTotalMatrix().isIdentity()) |
| 43 return true; | 43 return true; |
| 44 | 44 |
| 45 if (!canvas.isClipRect()) | 45 if (!canvas.isClipRect()) |
| 46 return true; | 46 return true; |
| 47 | 47 |
| 48 // Now we know the clip is a regular rectangle, make sure it covers the | 48 // Now we know the clip is a regular rectangle, make sure it covers the |
| 49 // entire canvas. | 49 // entire canvas. |
| 50 SkIRect clip_bounds; | 50 SkIRect clip_bounds; |
| 51 canvas.getClipDeviceBounds(&clip_bounds); | 51 canvas.getClipDeviceBounds(&clip_bounds); |
| 52 | 52 |
| 53 SkImageInfo info; | 53 SkImageInfo info; |
| 54 size_t row_bytes; | 54 size_t row_bytes; |
| 55 void* pixels = canvas.accessTopLayerPixels(&info, &row_bytes); | 55 void* pixels = GetSkCanvas(&canvas)->accessTopLayerPixels(&info, &row_bytes); |
| 56 DCHECK(pixels); | 56 DCHECK(pixels); |
| 57 if (!pixels) | 57 if (!pixels) |
| 58 return true; | 58 return true; |
| 59 | 59 |
| 60 if (clip_bounds.fLeft != 0 || clip_bounds.fTop != 0 || | 60 if (clip_bounds.fLeft != 0 || clip_bounds.fTop != 0 || |
| 61 clip_bounds.fRight != info.width() || | 61 clip_bounds.fRight != info.width() || |
| 62 clip_bounds.fBottom != info.height()) | 62 clip_bounds.fBottom != info.height()) |
| 63 return true; | 63 return true; |
| 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(CdlCanvas* 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) | 74 #if defined(OS_WIN) |
| 75 // If we have a PlatformCanvas, we should use ScrollDC. Otherwise, fall | 75 // If we have a PlatformCanvas, we should use ScrollDC. Otherwise, fall |
| 76 // through to the software implementation. | 76 // through to the software implementation. |
| 77 if (skia::SupportsPlatformPaint(canvas)) { | 77 if (skia::SupportsPlatformPaint(canvas)) { |
| 78 skia::ScopedPlatformPaint scoped_platform_paint(canvas); | 78 skia::ScopedPlatformPaint scoped_platform_paint(canvas); |
| 79 HDC hdc = scoped_platform_paint.GetNativeDrawingContext(); | 79 HDC hdc = scoped_platform_paint.GetNativeDrawingContext(); |
| 80 | 80 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // Fortunately, memmove already handles this for us. | 124 // Fortunately, memmove already handles this for us. |
| 125 for (int y = 0; y < dest_rect.height(); y++) { | 125 for (int y = 0; y < dest_rect.height(); y++) { |
| 126 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y), | 126 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y), |
| 127 pixmap.addr32(src_rect.x(), src_rect.y() + y), | 127 pixmap.addr32(src_rect.x(), src_rect.y() + y), |
| 128 row_bytes); | 128 row_bytes); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace gfx | 133 } // namespace gfx |
| OLD | NEW |