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

Side by Side Diff: cc/paint/draw_image.cc

Issue 2857923004: cc: Keep PaintImage in DrawImage. (Closed)
Patch Set: .. Created 3 years, 7 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
« no previous file with comments | « cc/paint/draw_image.h ('k') | cc/paint/image_id.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "cc/paint/draw_image.h" 5 #include "cc/paint/draw_image.h"
6 6
7 namespace cc { 7 namespace cc {
8 namespace { 8 namespace {
9 9
10 // Helper funciton to extract a scale from the matrix. Returns true on success 10 // Helper funciton to extract a scale from the matrix. Returns true on success
11 // and false on failure. 11 // and false on failure.
12 bool ExtractScale(const SkMatrix& matrix, SkSize* scale) { 12 bool ExtractScale(const SkMatrix& matrix, SkSize* scale) {
13 *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY()); 13 *scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY());
14 if (matrix.getType() & SkMatrix::kAffine_Mask) { 14 if (matrix.getType() & SkMatrix::kAffine_Mask) {
15 if (!matrix.decomposeScale(scale)) { 15 if (!matrix.decomposeScale(scale)) {
16 scale->set(1, 1); 16 scale->set(1, 1);
17 return false; 17 return false;
18 } 18 }
19 } 19 }
20 return true; 20 return true;
21 } 21 }
22 22
23 } // namespace 23 } // namespace
24 24
25 DrawImage::DrawImage() 25 DrawImage::DrawImage()
26 : image_(nullptr), 26 : src_rect_(SkIRect::MakeXYWH(0, 0, 0, 0)),
27 src_rect_(SkIRect::MakeXYWH(0, 0, 0, 0)),
28 filter_quality_(kNone_SkFilterQuality), 27 filter_quality_(kNone_SkFilterQuality),
29 matrix_(SkMatrix::I()), 28 matrix_(SkMatrix::I()),
30 scale_(SkSize::Make(1.f, 1.f)), 29 scale_(SkSize::Make(1.f, 1.f)),
31 matrix_is_decomposable_(true) {} 30 matrix_is_decomposable_(true) {}
32 31
33 DrawImage::DrawImage(sk_sp<const SkImage> image, 32 DrawImage::DrawImage(PaintImage image,
34 const SkIRect& src_rect, 33 const SkIRect& src_rect,
35 SkFilterQuality filter_quality, 34 SkFilterQuality filter_quality,
36 const SkMatrix& matrix, 35 const SkMatrix& matrix,
37 const gfx::ColorSpace& target_color_space) 36 const gfx::ColorSpace& target_color_space)
38 : image_(std::move(image)), 37 : paint_image_(std::move(image)),
39 src_rect_(src_rect), 38 src_rect_(src_rect),
40 filter_quality_(filter_quality), 39 filter_quality_(filter_quality),
41 matrix_(matrix), 40 matrix_(matrix),
42 target_color_space_(target_color_space) { 41 target_color_space_(target_color_space) {
43 matrix_is_decomposable_ = ExtractScale(matrix_, &scale_); 42 matrix_is_decomposable_ = ExtractScale(matrix_, &scale_);
44 } 43 }
45 44
46 DrawImage::DrawImage(const DrawImage& other) = default; 45 DrawImage::DrawImage(const DrawImage& other) = default;
47 46
48 DrawImage::~DrawImage() = default; 47 DrawImage::~DrawImage() = default;
49 48
50 } // namespace cc 49 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/draw_image.h ('k') | cc/paint/image_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698