| OLD | NEW |
| 1 // Copyright (c) 2009 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" |
| 11 #include "ui/gfx/point.h" | 11 #include "ui/gfx/point.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 cairo_set_source_surface(dst_context, cairo_get_target(src_context), | 84 cairo_set_source_surface(dst_context, cairo_get_target(src_context), |
| 85 dst_rect.x()-surface_x, dst_rect.y()-surface_y); | 85 dst_rect.x()-surface_x, dst_rect.y()-surface_y); |
| 86 cairo_rectangle(dst_context, dst_rect.x(), dst_rect.y(), | 86 cairo_rectangle(dst_context, dst_rect.x(), dst_rect.y(), |
| 87 dst_rect.width(), dst_rect.height()); | 87 dst_rect.width(), dst_rect.height()); |
| 88 cairo_clip(dst_context); | 88 cairo_clip(dst_context); |
| 89 cairo_paint(dst_context); | 89 cairo_paint(dst_context); |
| 90 cairo_restore(dst_context); | 90 cairo_restore(dst_context); |
| 91 #endif | 91 #endif |
| 92 } | 92 } |
| 93 | 93 |
| 94 static NativeDrawingContext GetContextFromCanvas( | |
| 95 skia::PlatformCanvas *canvas) { | |
| 96 skia::PlatformDevice& device = canvas->getTopPlatformDevice(); | |
| 97 #if defined(OS_WIN) | |
| 98 return device.getBitmapDC(); | |
| 99 #elif defined(OS_MACOSX) | |
| 100 return device.GetBitmapContext(); | |
| 101 #else // Linux, BSD, others | |
| 102 return device.beginPlatformPaint(); | |
| 103 #endif | |
| 104 } | |
| 105 | |
| 106 void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, | 94 void BlitContextToCanvas(skia::PlatformCanvas *dst_canvas, |
| 107 const Rect& dst_rect, | 95 const Rect& dst_rect, |
| 108 NativeDrawingContext src_context, | 96 NativeDrawingContext src_context, |
| 109 const Point& src_origin) { | 97 const Point& src_origin) { |
| 110 BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, | 98 BlitContextToContext(dst_canvas->beginPlatformPaint(), dst_rect, |
| 111 src_context, src_origin); | 99 src_context, src_origin); |
| 100 dst_canvas->endPlatformPaint(); |
| 112 } | 101 } |
| 113 | 102 |
| 114 void BlitCanvasToContext(NativeDrawingContext dst_context, | 103 void BlitCanvasToContext(NativeDrawingContext dst_context, |
| 115 const Rect& dst_rect, | 104 const Rect& dst_rect, |
| 116 skia::PlatformCanvas *src_canvas, | 105 skia::PlatformCanvas *src_canvas, |
| 117 const Point& src_origin) { | 106 const Point& src_origin) { |
| 118 BlitContextToContext(dst_context, dst_rect, | 107 BlitContextToContext(dst_context, dst_rect, |
| 119 GetContextFromCanvas(src_canvas), src_origin); | 108 src_canvas->beginPlatformPaint(), src_origin); |
| 109 src_canvas->endPlatformPaint(); |
| 120 } | 110 } |
| 121 | 111 |
| 122 void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, | 112 void BlitCanvasToCanvas(skia::PlatformCanvas *dst_canvas, |
| 123 const Rect& dst_rect, | 113 const Rect& dst_rect, |
| 124 skia::PlatformCanvas *src_canvas, | 114 skia::PlatformCanvas *src_canvas, |
| 125 const Point& src_origin) { | 115 const Point& src_origin) { |
| 126 BlitContextToContext(GetContextFromCanvas(dst_canvas), dst_rect, | 116 BlitContextToContext(dst_canvas->beginPlatformPaint(), dst_rect, |
| 127 GetContextFromCanvas(src_canvas), src_origin); | 117 src_canvas->beginPlatformPaint(), src_origin); |
| 118 src_canvas->endPlatformPaint(); |
| 119 dst_canvas->endPlatformPaint(); |
| 128 } | 120 } |
| 129 | 121 |
| 130 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
| 131 | 123 |
| 132 void ScrollCanvas(skia::PlatformCanvas* canvas, | 124 void ScrollCanvas(skia::PlatformCanvas* canvas, |
| 133 const gfx::Rect& clip, | 125 const gfx::Rect& clip, |
| 134 const gfx::Point& amount) { | 126 const gfx::Point& amount) { |
| 135 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. | 127 DCHECK(!HasClipOrTransform(*canvas)); // Don't support special stuff. |
| 136 HDC hdc = canvas->beginPlatformPaint(); | 128 HDC hdc = canvas->beginPlatformPaint(); |
| 137 | 129 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), | 185 memmove(bitmap.getAddr32(dest_rect.x(), dest_rect.y() + y), |
| 194 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), | 186 bitmap.getAddr32(src_rect.x(), src_rect.y() + y), |
| 195 row_bytes); | 187 row_bytes); |
| 196 } | 188 } |
| 197 } | 189 } |
| 198 } | 190 } |
| 199 | 191 |
| 200 #endif | 192 #endif |
| 201 | 193 |
| 202 } // namespace gfx | 194 } // namespace gfx |
| OLD | NEW |