summaryrefslogtreecommitdiffstats
path: root/cc/playback/draw_image.h
blob: 83b10ba3da992cc2cfe04fafbd3ccf024807d249 (plain)
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
// 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.

#ifndef CC_PLAYBACK_DRAW_IMAGE_H_
#define CC_PLAYBACK_DRAW_IMAGE_H_

#include "cc/base/cc_export.h"
#include "third_party/skia/include/core/SkFilterQuality.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkMatrix.h"

namespace cc {

// TODO(vmpstr): This should probably be DISALLOW_COPY_AND_ASSIGN and transport
// it around using a pointer, since it became kind of large. Profile.
class CC_EXPORT DrawImage {
 public:
  DrawImage();
  DrawImage(const SkImage* image,
            const SkIRect& src_rect,
            SkFilterQuality filter_quality,
            const SkMatrix& matrix);
  DrawImage(const DrawImage& other);

  const SkImage* image() const { return image_; }
  const SkSize& scale() const { return scale_; }
  const SkIRect src_rect() const { return src_rect_; }
  SkFilterQuality filter_quality() const { return filter_quality_; }
  bool matrix_is_decomposable() const { return matrix_is_decomposable_; }
  const SkMatrix& matrix() { return matrix_; }

  DrawImage ApplyScale(float scale) const {
    SkMatrix scaled_matrix = matrix_;
    scaled_matrix.postScale(scale, scale);
    return DrawImage(image_, src_rect_, filter_quality_, scaled_matrix);
  }

 private:
  const SkImage* image_;
  SkIRect src_rect_;
  SkFilterQuality filter_quality_;
  SkMatrix matrix_;
  SkSize scale_;
  bool matrix_is_decomposable_;
};

}  // namespace cc

#endif  // CC_PLAYBACK_DRAW_IMAGE_H_