Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: cc/paint/paint_surface.h

Issue 2690583002: Make cc/paint have concrete types (Closed)
Patch Set: PaintRecord as typedef, fixup playback calls Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/paint/paint_shader.h ('k') | cc/paint/paint_surface.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
9 #include "base/memory/ptr_util.h"
10 #include "base/optional.h"
11 #include "cc/paint/paint_canvas.h"
12 #include "cc/paint/paint_export.h"
8 #include "third_party/skia/include/core/SkSurface.h" 13 #include "third_party/skia/include/core/SkSurface.h"
9 14
10 namespace cc { 15 namespace cc {
11 using PaintSurface = SkSurface; 16
12 } 17 class CC_PAINT_EXPORT PaintSurface : public SkRefCntBase {
18 public:
19 explicit PaintSurface(sk_sp<SkSurface> surface);
20 ~PaintSurface() override;
21
22 // TODO(enne): this interface matches SkSurface for simplicity.
23 // However, this should really be changed to make the SkSurface ctor
24 // public and have that be the only constructor. This will also
25 // clean up a bunch of code where there's an SkSurface and a PaintCanvas,
26 // such as for canvas in Blink.
27 static sk_sp<PaintSurface> MakeRaster(const SkImageInfo& info,
28 const SkSurfaceProps* props = nullptr) {
29 sk_sp<SkSurface> s = SkSurface::MakeRaster(info, props);
30 return sk_make_sp<PaintSurface>(std::move(s));
31 }
32 static sk_sp<PaintSurface> MakeRasterN32Premul(
33 int width,
34 int height,
35 const SkSurfaceProps* props = nullptr) {
36 sk_sp<SkSurface> s = SkSurface::MakeRasterN32Premul(width, height, props);
37 return sk_make_sp<PaintSurface>(std::move(s));
38 }
39
40 int width() const { return surface_->width(); }
41 int height() const { return surface_->height(); }
42 uint32_t generationID() { return surface_->generationID(); }
43
44 PaintCanvas* getCanvas() {
45 if (!canvas_.has_value())
46 canvas_.emplace(surface_->getCanvas());
47 return &canvas_.value();
48 }
49
50 private:
51 const sk_sp<SkSurface> surface_;
52 base::Optional<PaintCanvas> canvas_;
53
54 DISALLOW_COPY_AND_ASSIGN(PaintSurface);
55 };
56
57 } // namespace cc
13 58
14 #endif // CC_PAINT_PAINT_SURFACE_H_ 59 #endif // CC_PAINT_PAINT_SURFACE_H_
OLDNEW
« no previous file with comments | « cc/paint/paint_shader.h ('k') | cc/paint/paint_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698