| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/gfx/platform_device_win.h" | 5 #include "PlatformDeviceWin.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/gfx/skia_utils.h" | 8 #include "base/gfx/skia_utils.h" |
| 9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 #include "SkPath.h" | 10 #include "SkPath.h" |
| 11 #include "SkRegion.h" | 11 #include "SkRegion.h" |
| 12 #include "SkUtils.h" | 12 #include "SkUtils.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 | 15 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 xf.eM21 = matrix[SkMatrix::kMSkewX]; | 125 xf.eM21 = matrix[SkMatrix::kMSkewX]; |
| 126 xf.eDx = matrix[SkMatrix::kMTransX]; | 126 xf.eDx = matrix[SkMatrix::kMTransX]; |
| 127 xf.eM12 = matrix[SkMatrix::kMSkewY]; | 127 xf.eM12 = matrix[SkMatrix::kMSkewY]; |
| 128 xf.eM22 = matrix[SkMatrix::kMScaleY]; | 128 xf.eM22 = matrix[SkMatrix::kMScaleY]; |
| 129 xf.eDy = matrix[SkMatrix::kMTransY]; | 129 xf.eDy = matrix[SkMatrix::kMTransY]; |
| 130 SetWorldTransform(dc, &xf); | 130 SetWorldTransform(dc, &xf); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // static | 133 // static |
| 134 bool PlatformDeviceWin::SkPathToCubicPaths(CubicPaths* paths, | 134 bool PlatformDeviceWin::SkPathToCubicPaths(CubicPaths* paths, |
| 135 const SkPath& skpath) { | 135 const SkPath& skpath) { |
| 136 paths->clear(); | 136 paths->clear(); |
| 137 CubicPath* current_path = NULL; | 137 CubicPath* current_path = NULL; |
| 138 SkPoint current_points[4]; | 138 SkPoint current_points[4]; |
| 139 CubicPoints points_to_add; | 139 CubicPoints points_to_add; |
| 140 SkPath::Iter iter(skpath, false); | 140 SkPath::Iter iter(skpath, false); |
| 141 for (SkPath::Verb verb = iter.next(current_points); | 141 for (SkPath::Verb verb = iter.next(current_points); |
| 142 verb != SkPath::kDone_Verb; | 142 verb != SkPath::kDone_Verb; |
| 143 verb = iter.next(current_points)) { | 143 verb = iter.next(current_points)) { |
| 144 switch (verb) { | 144 switch (verb) { |
| 145 case SkPath::kMove_Verb: { // iter.next returns 1 point | 145 case SkPath::kMove_Verb: { // iter.next returns 1 point |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 paths->clear(); | 188 paths->clear(); |
| 189 return false; | 189 return false; |
| 190 } | 190 } |
| 191 current_path->push_back(points_to_add); | 191 current_path->push_back(points_to_add); |
| 192 } | 192 } |
| 193 return true; | 193 return true; |
| 194 } | 194 } |
| 195 | 195 |
| 196 // static | 196 // static |
| 197 void PlatformDeviceWin::LoadClippingRegionToDC(HDC context, | 197 void PlatformDeviceWin::LoadClippingRegionToDC(HDC context, |
| 198 const SkRegion& region, | 198 const SkRegion& region, |
| 199 const SkMatrix& transformation) { | 199 const SkMatrix& transformation) { |
| 200 HRGN hrgn; | 200 HRGN hrgn; |
| 201 if (region.isEmpty()) { | 201 if (region.isEmpty()) { |
| 202 // region can be empty, in which case everything will be clipped. | 202 // region can be empty, in which case everything will be clipped. |
| 203 hrgn = CreateRectRgn(0, 0, 0, 0); | 203 hrgn = CreateRectRgn(0, 0, 0, 0); |
| 204 } else if (region.isRect()) { | 204 } else if (region.isRect()) { |
| 205 // Do the transformation. | 205 // Do the transformation. |
| 206 SkRect rect; | 206 SkRect rect; |
| 207 rect.set(region.getBounds()); | 207 rect.set(region.getBounds()); |
| 208 transformation.mapRect(&rect); | 208 transformation.mapRect(&rect); |
| 209 SkIRect irect; | 209 SkIRect irect; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 220 hrgn = PathToRegion(context); | 220 hrgn = PathToRegion(context); |
| 221 } | 221 } |
| 222 int result = SelectClipRgn(context, hrgn); | 222 int result = SelectClipRgn(context, hrgn); |
| 223 DCHECK_NE(result, ERROR); | 223 DCHECK_NE(result, ERROR); |
| 224 result = DeleteObject(hrgn); | 224 result = DeleteObject(hrgn); |
| 225 DCHECK_NE(result, 0); | 225 DCHECK_NE(result, 0); |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace gfx | 228 } // namespace gfx |
| 229 | 229 |
| OLD | NEW |