Chromium Code Reviews| Index: cc/resources/resource_helper.h |
| diff --git a/cc/resources/resource_helper.h b/cc/resources/resource_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0dfdb24a6a90ee018328ad492083490fe826de17 |
| --- /dev/null |
| +++ b/cc/resources/resource_helper.h |
| @@ -0,0 +1,75 @@ |
| +// Copyright 2012 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_RESOURCES_RESOURCE_HELPER_H_ |
| +#define CC_RESOURCES_RESOURCE_HELPER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "cc/base/cc_export.h" |
| +#include "cc/output/context_provider.h" |
| +#include "cc/output/output_surface.h" |
| +#include "third_party/khronos/GLES2/gl2.h" |
| +#include "third_party/khronos/GLES2/gl2ext.h" |
| + |
| +class GrContext; |
| + |
| +namespace gpu { |
| +namespace gles { |
| +class GLES2Interface; |
| +} |
| +} |
| + |
| +namespace cc { |
| + |
| +class CC_EXPORT ResourceHelper { |
| + public: |
| + ResourceHelper(OutputSurface* output_surface); |
| + ~ResourceHelper(); |
| + |
| + // The following class is needed to modify GL resources using GPU |
| + // raster. The user must ensure that they only use GPU raster on |
| + // GL resources while an instance of this class is alive. |
| + 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.
|
| + public: |
| + ScopedGpuRaster(ResourceHelper* resource_helper); |
| + ~ScopedGpuRaster(); |
| + |
| + private: |
| + void BeginGpuRaster(); |
| + void EndGpuRaster(); |
| + |
| + ResourceHelper* resource_helper_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedGpuRaster); |
| + }; |
| + |
| + // Flush all context operations, kicking uploads and ensuring ordering with |
| + // respect to other contexts. |
| + void Flush(); |
| + |
| + // Finish all context operations, causing any pending callbacks to be |
| + // scheduled. |
| + void Finish(); |
| + |
| + static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl); |
| + |
| + // Only flush the command buffer if supported. |
| + // Returns true if the shallow flush occurred, false otherwise. |
| + bool ShallowFlushIfSupported(); |
| + |
| + // Returns NULL if the output_surface_ does not have a ContextProvider. |
| + gpu::gles2::GLES2Interface* ContextGL() const; |
| + class GrContext* GrContext() const; |
| + |
| + private: |
| + OutputSurface* output_surface_; |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ResourceHelper); |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_RESOURCES_RESOURCE_HELPER_H_ |