OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_PAINT_SURFACE_H_ | 5 #ifndef CC_PAINT_PAINT_SURFACE_H_ |
6 #define CC_PAINT_PAINT_SURFACE_H_ | 6 #define CC_PAINT_PAINT_SURFACE_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/optional.h" | 10 #include "base/optional.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 static sk_sp<PaintSurface> MakeRasterN32Premul( | 32 static sk_sp<PaintSurface> MakeRasterN32Premul( |
33 int width, | 33 int width, |
34 int height, | 34 int height, |
35 const SkSurfaceProps* props = nullptr) { | 35 const SkSurfaceProps* props = nullptr) { |
36 sk_sp<SkSurface> s = SkSurface::MakeRasterN32Premul(width, height, props); | 36 sk_sp<SkSurface> s = SkSurface::MakeRasterN32Premul(width, height, props); |
37 return sk_make_sp<PaintSurface>(std::move(s)); | 37 return sk_make_sp<PaintSurface>(std::move(s)); |
38 } | 38 } |
39 | 39 |
40 int width() const { return surface_->width(); } | 40 int width() const { return surface_->width(); } |
41 int height() const { return surface_->height(); } | 41 int height() const { return surface_->height(); } |
42 uint32_t generationID() { return surface_->generationID(); } | |
43 | 42 |
44 PaintCanvas* getCanvas() { | 43 PaintCanvas* getCanvas() { |
45 if (!canvas_.has_value()) | 44 if (!canvas_.has_value()) |
46 canvas_.emplace(surface_->getCanvas()); | 45 canvas_.emplace(surface_->getCanvas()); |
47 return &canvas_.value(); | 46 return &canvas_.value(); |
48 } | 47 } |
49 | 48 |
50 private: | 49 private: |
51 const sk_sp<SkSurface> surface_; | 50 const sk_sp<SkSurface> surface_; |
52 base::Optional<SkiaPaintCanvas> canvas_; | 51 base::Optional<SkiaPaintCanvas> canvas_; |
53 | 52 |
54 DISALLOW_COPY_AND_ASSIGN(PaintSurface); | 53 DISALLOW_COPY_AND_ASSIGN(PaintSurface); |
55 }; | 54 }; |
56 | 55 |
57 } // namespace cc | 56 } // namespace cc |
58 | 57 |
59 #endif // CC_PAINT_PAINT_SURFACE_H_ | 58 #endif // CC_PAINT_PAINT_SURFACE_H_ |
OLD | NEW |