OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_RESOURCES_RESOURCE_HELPER_H_ | |
6 #define CC_RESOURCES_RESOURCE_HELPER_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/threading/thread_checker.h" | |
10 #include "cc/base/cc_export.h" | |
11 #include "cc/output/context_provider.h" | |
12 #include "cc/output/output_surface.h" | |
13 #include "third_party/khronos/GLES2/gl2.h" | |
14 #include "third_party/khronos/GLES2/gl2ext.h" | |
15 | |
16 class GrContext; | |
17 | |
18 namespace gpu { | |
19 namespace gles { | |
20 class GLES2Interface; | |
21 } | |
22 } | |
23 | |
24 namespace cc { | |
25 | |
26 class CC_EXPORT ResourceHelper { | |
27 public: | |
28 ResourceHelper(OutputSurface* output_surface); | |
29 ~ResourceHelper(); | |
30 | |
31 // The following class is needed to modify GL resources using GPU | |
32 // raster. The user must ensure that they only use GPU raster on | |
33 // GL resources while an instance of this class is alive. | |
34 class CC_EXPORT ScopedGpuRaster { | |
danakj
2014/07/09 16:01:33
How about making this a top-level class instead of
sohanjg
2014/07/10 15:11:06
Done.
| |
35 public: | |
36 ScopedGpuRaster(ResourceHelper* resource_helper); | |
37 ~ScopedGpuRaster(); | |
38 | |
39 private: | |
40 void BeginGpuRaster(); | |
41 void EndGpuRaster(); | |
42 | |
43 ResourceHelper* resource_helper_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(ScopedGpuRaster); | |
46 }; | |
47 | |
48 // Flush all context operations, kicking uploads and ensuring ordering with | |
49 // respect to other contexts. | |
50 void Flush(); | |
51 | |
52 // Finish all context operations, causing any pending callbacks to be | |
53 // scheduled. | |
54 void Finish(); | |
55 | |
56 static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); | |
57 | |
58 // Only flush the command buffer if supported. | |
59 // Returns true if the shallow flush occurred, false otherwise. | |
60 bool ShallowFlushIfSupported(); | |
61 | |
62 // Returns NULL if the output_surface_ does not have a ContextProvider. | |
63 gpu::gles2::GLES2Interface* ContextGL() const; | |
64 class GrContext* GrContext() const; | |
65 | |
66 private: | |
67 OutputSurface* output_surface_; | |
68 base::ThreadChecker thread_checker_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(ResourceHelper); | |
71 }; | |
72 | |
73 } // namespace cc | |
74 | |
75 #endif // CC_RESOURCES_RESOURCE_HELPER_H_ | |
OLD | NEW |