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

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

Issue 1497543004: ui/gfx: Add MapRect and ExtractScale skia helper functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « ui/gfx/skia_util.h ('k') | 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/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include "third_party/skia/include/core/SkBitmap.h" 7 #include "third_party/skia/include/core/SkBitmap.h"
8 #include "third_party/skia/include/core/SkColorFilter.h" 8 #include "third_party/skia/include/core/SkColorFilter.h"
9 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkUnPreMultiply.h" 10 #include "third_party/skia/include/core/SkUnPreMultiply.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 216 }
217 } 217 }
218 218
219 void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) { 219 void QuadFToSkPoints(const gfx::QuadF& quad, SkPoint points[4]) {
220 points[0] = PointFToSkPoint(quad.p1()); 220 points[0] = PointFToSkPoint(quad.p1());
221 points[1] = PointFToSkPoint(quad.p2()); 221 points[1] = PointFToSkPoint(quad.p2());
222 points[2] = PointFToSkPoint(quad.p3()); 222 points[2] = PointFToSkPoint(quad.p3());
223 points[3] = PointFToSkPoint(quad.p4()); 223 points[3] = PointFToSkPoint(quad.p4());
224 } 224 }
225 225
226 bool ExtractScale(const SkMatrix& matrix, SkSize* scale) {
227 *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY());
228 if (matrix.getType() & SkMatrix::kAffine_Mask) {
229 if (!matrix.decomposeScale(scale)) {
230 scale->set(1.f, 1.f);
231 return false;
232 }
233 }
234 return true;
235 }
236
237 SkRect MapRect(const SkMatrix& matrix, const SkRect& src) {
danakj 2015/12/03 00:12:35 I question why you're using an SkMatrix and not a
238 SkRect dst;
239 matrix.mapRect(&dst, src);
240 return dst;
241 }
242
226 } // namespace gfx 243 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/skia_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698