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

Side by Side Diff: ui/gfx/blit.cc

Issue 2593803004: simplify scrollcanvas to always use shared code (Closed)
Patch Set: just use DCHECK Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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;
82 RECT r = in_clip.ToRECT();
83 ScrollDC(hdc, offset.x(), offset.y(), NULL, &r, NULL, &damaged_rect);
84 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; 75 SkPixmap pixmap;
92 skia::GetWritablePixels(canvas, &pixmap); 76 bool success = skia::GetWritablePixels(canvas, &pixmap);
77 DCHECK(success);
93 78
94 // We expect all coords to be inside the canvas, so clip here. 79 // We expect all coords to be inside the canvas, so clip here.
95 gfx::Rect clip = gfx::IntersectRects( 80 gfx::Rect clip = gfx::IntersectRects(
96 in_clip, gfx::Rect(0, 0, pixmap.width(), pixmap.height())); 81 in_clip, gfx::Rect(0, 0, pixmap.width(), pixmap.height()));
97 82
98 // Compute the set of pixels we'll actually end up painting. 83 // Compute the set of pixels we'll actually end up painting.
99 gfx::Rect dest_rect = gfx::IntersectRects(clip + offset, clip); 84 gfx::Rect dest_rect = gfx::IntersectRects(clip + offset, clip);
100 if (dest_rect.size().IsEmpty()) 85 if (dest_rect.size().IsEmpty())
101 return; // Nothing to do. 86 return; // Nothing to do.
102 87
(...skipping 21 matching lines...) Expand all
124 // Fortunately, memmove already handles this for us. 109 // Fortunately, memmove already handles this for us.
125 for (int y = 0; y < dest_rect.height(); y++) { 110 for (int y = 0; y < dest_rect.height(); y++) {
126 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y), 111 memmove(pixmap.writable_addr32(dest_rect.x(), dest_rect.y() + y),
127 pixmap.addr32(src_rect.x(), src_rect.y() + y), 112 pixmap.addr32(src_rect.x(), src_rect.y() + y),
128 row_bytes); 113 row_bytes);
129 } 114 }
130 } 115 }
131 } 116 }
132 117
133 } // namespace gfx 118 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698