OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ | 5 #ifndef MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ |
6 #define MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ | 6 #define MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "mojo/skia/ganesh_context.h" | 11 #include "mojo/skia/ganesh_context.h" |
12 #include "skia/ext/refptr.h" | 12 #include "third_party/skia/include/core/SkRefCnt.h" |
13 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 class GLTexture; | 16 class GLTexture; |
17 | 17 |
18 namespace skia { | 18 namespace skia { |
19 | 19 |
20 // This class represents an SkSurface backed by a GL texture, which is | 20 // This class represents an SkSurface backed by a GL texture, which is |
21 // appropriate for use with Ganesh. This is useful for rendering Skia | 21 // appropriate for use with Ganesh. This is useful for rendering Skia |
22 // commands to a texture. | 22 // commands to a texture. |
23 class GaneshTextureSurface { | 23 class GaneshTextureSurface { |
24 public: | 24 public: |
25 // Creates a surface that wraps the specified GL texture. | 25 // Creates a surface that wraps the specified GL texture. |
26 GaneshTextureSurface(const GaneshContext::Scope& scope, | 26 GaneshTextureSurface(const GaneshContext::Scope& scope, |
27 std::unique_ptr<GLTexture> texture); | 27 std::unique_ptr<GLTexture> texture); |
28 ~GaneshTextureSurface(); | 28 ~GaneshTextureSurface(); |
29 | 29 |
30 SkSurface* surface() const { return surface_.get(); } | 30 SkSurface* surface() const { return surface_.get(); } |
31 SkCanvas* canvas() const { return surface_->getCanvas(); } | 31 SkCanvas* canvas() const { return surface_->getCanvas(); } |
32 | 32 |
33 // Destroys the surface and returns its underlying texture. | 33 // Destroys the surface and returns its underlying texture. |
34 std::unique_ptr<GLTexture> TakeTexture(); | 34 std::unique_ptr<GLTexture> TakeTexture(); |
35 | 35 |
36 private: | 36 private: |
37 std::unique_ptr<GLTexture> texture_; | 37 std::unique_ptr<GLTexture> texture_; |
38 ::skia::RefPtr<SkSurface> surface_; | 38 sk_sp<SkSurface> surface_; |
39 | 39 |
40 DISALLOW_COPY_AND_ASSIGN(GaneshTextureSurface); | 40 DISALLOW_COPY_AND_ASSIGN(GaneshTextureSurface); |
41 }; | 41 }; |
42 | 42 |
43 } // namespace skia | 43 } // namespace skia |
44 } // namespace mojo | 44 } // namespace mojo |
45 | 45 |
46 #endif // MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ | 46 #endif // MOJO_SKIA_GANESH_TEXTURE_SURFACE_H_ |
OLD | NEW |