| 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_PLAYBACK_DECODED_DRAW_IMAGE_H_ | 5 #ifndef CC_PLAYBACK_DECODED_DRAW_IMAGE_H_ |
| 6 #define CC_PLAYBACK_DECODED_DRAW_IMAGE_H_ | 6 #define CC_PLAYBACK_DECODED_DRAW_IMAGE_H_ |
| 7 | 7 |
| 8 #include <cfloat> | 8 #include <cfloat> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| 11 #include "cc/base/cc_export.h" |
| 11 #include "third_party/skia/include/core/SkFilterQuality.h" | 12 #include "third_party/skia/include/core/SkFilterQuality.h" |
| 12 #include "third_party/skia/include/core/SkImage.h" | 13 #include "third_party/skia/include/core/SkImage.h" |
| 14 #include "third_party/skia/include/core/SkRefCnt.h" |
| 13 #include "third_party/skia/include/core/SkSize.h" | 15 #include "third_party/skia/include/core/SkSize.h" |
| 14 | 16 |
| 15 namespace cc { | 17 namespace cc { |
| 16 | 18 |
| 17 class DecodedDrawImage { | 19 class CC_EXPORT DecodedDrawImage { |
| 18 public: | 20 public: |
| 19 DecodedDrawImage(const SkImage* image, | 21 DecodedDrawImage(sk_sp<const SkImage> image, |
| 20 const SkSize& src_rect_offset, | 22 const SkSize& src_rect_offset, |
| 21 const SkSize& scale_adjustment, | 23 const SkSize& scale_adjustment, |
| 22 SkFilterQuality filter_quality) | 24 SkFilterQuality filter_quality); |
| 23 : image_(image), | 25 DecodedDrawImage(sk_sp<const SkImage> image, SkFilterQuality filter_quality); |
| 24 src_rect_offset_(src_rect_offset), | 26 DecodedDrawImage(const DecodedDrawImage& other); |
| 25 scale_adjustment_(scale_adjustment), | 27 ~DecodedDrawImage(); |
| 26 filter_quality_(filter_quality), | |
| 27 at_raster_decode_(false) {} | |
| 28 | 28 |
| 29 DecodedDrawImage(const SkImage* image, SkFilterQuality filter_quality) | 29 const sk_sp<const SkImage>& image() const { return image_; } |
| 30 : image_(image), | |
| 31 src_rect_offset_(SkSize::Make(0.f, 0.f)), | |
| 32 scale_adjustment_(SkSize::Make(1.f, 1.f)), | |
| 33 filter_quality_(filter_quality), | |
| 34 at_raster_decode_(false) {} | |
| 35 | |
| 36 const SkImage* image() const { return image_; } | |
| 37 const SkSize& src_rect_offset() const { return src_rect_offset_; } | 30 const SkSize& src_rect_offset() const { return src_rect_offset_; } |
| 38 const SkSize& scale_adjustment() const { return scale_adjustment_; } | 31 const SkSize& scale_adjustment() const { return scale_adjustment_; } |
| 39 SkFilterQuality filter_quality() const { return filter_quality_; } | 32 SkFilterQuality filter_quality() const { return filter_quality_; } |
| 40 bool is_scale_adjustment_identity() const { | 33 bool is_scale_adjustment_identity() const { |
| 41 return std::abs(scale_adjustment_.width() - 1.f) < FLT_EPSILON && | 34 return std::abs(scale_adjustment_.width() - 1.f) < FLT_EPSILON && |
| 42 std::abs(scale_adjustment_.height() - 1.f) < FLT_EPSILON; | 35 std::abs(scale_adjustment_.height() - 1.f) < FLT_EPSILON; |
| 43 } | 36 } |
| 44 | 37 |
| 45 void set_at_raster_decode(bool at_raster_decode) { | 38 void set_at_raster_decode(bool at_raster_decode) { |
| 46 at_raster_decode_ = at_raster_decode; | 39 at_raster_decode_ = at_raster_decode; |
| 47 } | 40 } |
| 48 bool is_at_raster_decode() const { return at_raster_decode_; } | 41 bool is_at_raster_decode() const { return at_raster_decode_; } |
| 49 | 42 |
| 50 private: | 43 private: |
| 51 const SkImage* image_; | 44 sk_sp<const SkImage> image_; |
| 52 const SkSize src_rect_offset_; | 45 const SkSize src_rect_offset_; |
| 53 const SkSize scale_adjustment_; | 46 const SkSize scale_adjustment_; |
| 54 const SkFilterQuality filter_quality_; | 47 const SkFilterQuality filter_quality_; |
| 55 bool at_raster_decode_; | 48 bool at_raster_decode_; |
| 56 }; | 49 }; |
| 57 | 50 |
| 58 } // namespace cc | 51 } // namespace cc |
| 59 | 52 |
| 60 #endif // CC_PLAYBACK_DECODED_DRAW_IMAGE_H_ | 53 #endif // CC_PLAYBACK_DECODED_DRAW_IMAGE_H_ |
| OLD | NEW |