forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_image.cc
52 lines (44 loc) · 1.51 KB
/
draw_image.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/playback/draw_image.h"
namespace cc {
namespace {
// Helper funciton to extract a scale from the matrix. Returns true on success
// and false on failure.
bool ExtractScale(const SkMatrix& matrix, SkSize* scale) {
*scale = SkSize::Make(matrix.getScaleX(), matrix.getScaleY());
if (matrix.getType() & SkMatrix::kAffine_Mask) {
if (!matrix.decomposeScale(scale)) {
scale->set(1, 1);
return false;
}
}
return true;
}
} // namespace
DrawImage::DrawImage()
: image_(nullptr),
src_rect_(SkIRect::MakeXYWH(0, 0, 0, 0)),
filter_quality_(kNone_SkFilterQuality),
matrix_(SkMatrix::I()),
scale_(SkSize::Make(1.f, 1.f)),
matrix_is_decomposable_(true) {}
DrawImage::DrawImage(const SkImage* image,
const SkIRect& src_rect,
SkFilterQuality filter_quality,
const SkMatrix& matrix)
: image_(image),
src_rect_(src_rect),
filter_quality_(filter_quality),
matrix_(matrix) {
matrix_is_decomposable_ = ExtractScale(matrix_, &scale_);
}
DrawImage::DrawImage(const DrawImage& other)
: image_(other.image_),
src_rect_(other.src_rect_),
filter_quality_(other.filter_quality_),
matrix_(other.matrix_),
scale_(other.scale_),
matrix_is_decomposable_(other.matrix_is_decomposable_) {}
} // namespace cc