OLD | NEW |
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 #ifndef CC_PAINT_DRAW_IMAGE_H_ | 5 #ifndef CC_PAINT_DRAW_IMAGE_H_ |
6 #define CC_PAINT_DRAW_IMAGE_H_ | 6 #define CC_PAINT_DRAW_IMAGE_H_ |
7 | 7 |
8 #include "cc/paint/paint_export.h" | 8 #include "cc/paint/paint_export.h" |
9 #include "third_party/skia/include/core/SkFilterQuality.h" | 9 #include "third_party/skia/include/core/SkFilterQuality.h" |
10 #include "third_party/skia/include/core/SkImage.h" | 10 #include "third_party/skia/include/core/SkImage.h" |
11 #include "third_party/skia/include/core/SkMatrix.h" | 11 #include "third_party/skia/include/core/SkMatrix.h" |
12 #include "third_party/skia/include/core/SkRect.h" | 12 #include "third_party/skia/include/core/SkRect.h" |
13 #include "third_party/skia/include/core/SkRefCnt.h" | 13 #include "third_party/skia/include/core/SkRefCnt.h" |
| 14 #include "ui/gfx/color_space.h" |
14 #include "ui/gfx/geometry/size_f.h" | 15 #include "ui/gfx/geometry/size_f.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 | 18 |
18 // TODO(vmpstr): This should probably be DISALLOW_COPY_AND_ASSIGN and transport | 19 // TODO(vmpstr): This should probably be DISALLOW_COPY_AND_ASSIGN and transport |
19 // it around using a pointer, since it became kind of large. Profile. | 20 // it around using a pointer, since it became kind of large. Profile. |
20 class CC_PAINT_EXPORT DrawImage { | 21 class CC_PAINT_EXPORT DrawImage { |
21 public: | 22 public: |
22 DrawImage(); | 23 DrawImage(); |
23 DrawImage(sk_sp<const SkImage> image, | 24 DrawImage(sk_sp<const SkImage> image, |
24 const SkIRect& src_rect, | 25 const SkIRect& src_rect, |
25 SkFilterQuality filter_quality, | 26 SkFilterQuality filter_quality, |
26 const SkMatrix& matrix); | 27 const SkMatrix& matrix, |
| 28 const gfx::ColorSpace& target_color_space); |
27 DrawImage(const DrawImage& other); | 29 DrawImage(const DrawImage& other); |
28 ~DrawImage(); | 30 ~DrawImage(); |
29 | 31 |
30 const sk_sp<const SkImage>& image() const { return image_; } | 32 const sk_sp<const SkImage>& image() const { return image_; } |
31 const SkSize& scale() const { return scale_; } | 33 const SkSize& scale() const { return scale_; } |
32 const SkIRect& src_rect() const { return src_rect_; } | 34 const SkIRect& src_rect() const { return src_rect_; } |
33 SkFilterQuality filter_quality() const { return filter_quality_; } | 35 SkFilterQuality filter_quality() const { return filter_quality_; } |
34 bool matrix_is_decomposable() const { return matrix_is_decomposable_; } | 36 bool matrix_is_decomposable() const { return matrix_is_decomposable_; } |
35 const SkMatrix& matrix() const { return matrix_; } | 37 const SkMatrix& matrix() const { return matrix_; } |
| 38 const gfx::ColorSpace& target_color_space() const { |
| 39 return target_color_space_; |
| 40 } |
36 | 41 |
37 DrawImage ApplyScale(float scale) const { | 42 DrawImage ApplyScale(float scale) const { |
38 SkMatrix scaled_matrix = matrix_; | 43 SkMatrix scaled_matrix = matrix_; |
39 scaled_matrix.preScale(scale, scale); | 44 scaled_matrix.preScale(scale, scale); |
40 return DrawImage(image_, src_rect_, filter_quality_, scaled_matrix); | 45 return DrawImage(image_, src_rect_, filter_quality_, scaled_matrix, |
| 46 target_color_space_); |
| 47 } |
| 48 DrawImage ApplyTargetColorSpace(const gfx::ColorSpace& target_color_space) { |
| 49 return DrawImage(image_, src_rect_, filter_quality_, matrix_, |
| 50 target_color_space); |
41 } | 51 } |
42 | 52 |
43 private: | 53 private: |
44 sk_sp<const SkImage> image_; | 54 sk_sp<const SkImage> image_; |
45 SkIRect src_rect_; | 55 SkIRect src_rect_; |
46 SkFilterQuality filter_quality_; | 56 SkFilterQuality filter_quality_; |
47 SkMatrix matrix_; | 57 SkMatrix matrix_; |
48 SkSize scale_; | 58 SkSize scale_; |
49 bool matrix_is_decomposable_; | 59 bool matrix_is_decomposable_; |
| 60 gfx::ColorSpace target_color_space_; |
50 }; | 61 }; |
51 | 62 |
52 } // namespace cc | 63 } // namespace cc |
53 | 64 |
54 #endif // CC_PAINT_DRAW_IMAGE_H_ | 65 #endif // CC_PAINT_DRAW_IMAGE_H_ |
OLD | NEW |