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

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

Issue 10915065: Add PlatformPictureSkia and RecordingPlatformDeviceSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: And one more.. Created 8 years, 2 months 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 | Annotate | Revision Log
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 "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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 cairo_clip(dst_context); 91 cairo_clip(dst_context);
92 cairo_paint(dst_context); 92 cairo_paint(dst_context);
93 cairo_restore(dst_context); 93 cairo_restore(dst_context);
94 #endif 94 #endif
95 } 95 }
96 96
97 void BlitContextToCanvas(SkCanvas *dst_canvas, 97 void BlitContextToCanvas(SkCanvas *dst_canvas,
98 const Rect& dst_rect, 98 const Rect& dst_rect,
99 NativeDrawingContext src_context, 99 NativeDrawingContext src_context,
100 const Point& src_origin) { 100 const Point& src_origin) {
101 DCHECK(skia::SupportsPlatformPaint(dst_canvas)); 101 DCHECK(skia::PlatformPaintSupport(dst_canvas));
102 BlitContextToContext(skia::BeginPlatformPaint(dst_canvas), dst_rect, 102 BlitContextToContext(skia::BeginPlatformPaint(dst_canvas), dst_rect,
103 src_context, src_origin); 103 src_context, src_origin);
104 skia::EndPlatformPaint(dst_canvas); 104 skia::EndPlatformPaint(dst_canvas);
105 } 105 }
106 106
107 void BlitCanvasToContext(NativeDrawingContext dst_context, 107 void BlitCanvasToContext(NativeDrawingContext dst_context,
108 const Rect& dst_rect, 108 const Rect& dst_rect,
109 SkCanvas *src_canvas, 109 SkCanvas *src_canvas,
110 const Point& src_origin) { 110 const Point& src_origin) {
111 DCHECK(skia::SupportsPlatformPaint(src_canvas)); 111 DCHECK(skia::PlatformPaintSupport(src_canvas));
112 BlitContextToContext(dst_context, dst_rect, 112 BlitContextToContext(dst_context, dst_rect,
113 skia::BeginPlatformPaint(src_canvas), src_origin); 113 skia::BeginPlatformPaint(src_canvas), src_origin);
114 skia::EndPlatformPaint(src_canvas); 114 skia::EndPlatformPaint(src_canvas);
115 } 115 }
116 116
117 void BlitCanvasToCanvas(SkCanvas *dst_canvas, 117 void BlitCanvasToCanvas(SkCanvas *dst_canvas,
118 const Rect& dst_rect, 118 const Rect& dst_rect,
119 SkCanvas *src_canvas, 119 SkCanvas *src_canvas,
120 const Point& src_origin) { 120 const Point& src_origin) {
121 DCHECK(skia::SupportsPlatformPaint(dst_canvas)); 121 DCHECK(skia::PlatformPaintSupport(dst_canvas));
122 DCHECK(skia::SupportsPlatformPaint(src_canvas)); 122 DCHECK(skia::PlatformPaintSupport(src_canvas));
123 BlitContextToContext(skia::BeginPlatformPaint(dst_canvas), dst_rect, 123 BlitContextToContext(skia::BeginPlatformPaint(dst_canvas), dst_rect,
124 skia::BeginPlatformPaint(src_canvas), src_origin); 124 skia::BeginPlatformPaint(src_canvas), src_origin);
125 skia::EndPlatformPaint(src_canvas); 125 skia::EndPlatformPaint(src_canvas);
126 skia::EndPlatformPaint(dst_canvas); 126 skia::EndPlatformPaint(dst_canvas);
127 } 127 }
128 128
129 void ScrollCanvas(SkCanvas* canvas, 129 void ScrollCanvas(SkCanvas* canvas,
130 const gfx::Rect& in_clip, 130 const gfx::Rect& in_clip,
131 const gfx::Point& amount) { 131 const gfx::Point& amount) {
132 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. 132 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff.
133 #if defined(OS_WIN) 133 #if defined(OS_WIN)
134 // If we have a PlatformCanvas, we should use ScrollDC. Otherwise, fall 134 // If we have a PlatformCanvas, we should use ScrollDC. Otherwise, fall
135 // through to the software implementation. 135 // through to the software implementation.
136 if (skia::SupportsPlatformPaint(canvas)) { 136 if (skia::PlatformPaintSupport(canvas) ==
137 skia::PlatformDevice::PLATFORM_PAINT_DIRECT) {
137 skia::ScopedPlatformPaint scoped_platform_paint(canvas); 138 skia::ScopedPlatformPaint scoped_platform_paint(canvas);
138 HDC hdc = scoped_platform_paint.GetPlatformSurface(); 139 HDC hdc = scoped_platform_paint.GetPlatformSurface();
139 140
140 RECT damaged_rect; 141 RECT damaged_rect;
141 RECT r = in_clip.ToRECT(); 142 RECT r = in_clip.ToRECT();
142 ScrollDC(hdc, amount.x(), amount.y(), NULL, &r, NULL, &damaged_rect); 143 ScrollDC(hdc, amount.x(), amount.y(), NULL, &r, NULL, &damaged_rect);
143 return; 144 return;
144 } 145 }
145 #endif // defined(OS_WIN) 146 #endif // defined(OS_WIN)
146 // For non-windows, always do scrolling in software. 147 // For non-windows, always do scrolling in software.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Fortunately, memmove already handles this for us. 188 // Fortunately, memmove already handles this for us.
188 for (int y = 0; y < dest_rect.height(); y++) { 189 for (int y = 0; y < dest_rect.height(); y++) {
189 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), 190 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y),
190 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), 191 bitmap.getAddr32(src_rect.x(), src_rect.y() + y),
191 row_bytes); 192 row_bytes);
192 } 193 }
193 } 194 }
194 } 195 }
195 196
196 } // namespace gfx 197 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698