grcontext_for_gles2_interface.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2013 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. #ifndef GPU_SKIA_BINDINGS_GRCONTEXT_FOR_GLES2_INTERFACE_H_
  5. #define GPU_SKIA_BINDINGS_GRCONTEXT_FOR_GLES2_INTERFACE_H_
  6. #include "base/memory/raw_ptr.h"
  7. #include "third_party/skia/include/core/SkRefCnt.h"
  8. #include "third_party/skia/include/gpu/GrContextOptions.h"
  9. namespace gpu {
  10. struct Capabilities;
  11. class ContextSupport;
  12. namespace gles2 {
  13. class GLES2Interface;
  14. }
  15. }
  16. namespace skia_bindings {
  17. // This class binds an offscreen GrContext to an offscreen context3d. The
  18. // context3d is used by the GrContext so must be valid as long as this class
  19. // is alive.
  20. class GrContextForGLES2Interface : public GrContextOptions::ShaderErrorHandler {
  21. public:
  22. GrContextForGLES2Interface(gpu::gles2::GLES2Interface* gl,
  23. gpu::ContextSupport* context_support,
  24. const gpu::Capabilities& capabilities,
  25. size_t max_resource_cache_bytes,
  26. size_t max_glyph_cache_texture_bytes,
  27. bool support_bilerp_from_flyph_atlas = false);
  28. GrContextForGLES2Interface(const GrContextForGLES2Interface&) = delete;
  29. GrContextForGLES2Interface& operator=(const GrContextForGLES2Interface&) =
  30. delete;
  31. ~GrContextForGLES2Interface() override;
  32. // Handles Skia-reported shader compilation errors.
  33. void compileError(const char* shader, const char* errors) override;
  34. GrDirectContext* get();
  35. void OnLostContext();
  36. void FreeGpuResources();
  37. private:
  38. sk_sp<class GrDirectContext> gr_context_;
  39. raw_ptr<gpu::ContextSupport> context_support_;
  40. };
  41. } // namespace skia_bindings
  42. #endif // GPU_SKIA_BINDINGS_GRCONTEXT_FOR_GLES2_INTERFACE_H_