| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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 GPU_GLES2_CONFORM_TEST_CONTEXT_H_ | |
| 6 #define GPU_GLES2_CONFORM_TEST_CONTEXT_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | |
| 11 #include "gpu/command_buffer/client/gpu_control.h" | |
| 12 #include "gpu/command_buffer/service/command_buffer_service.h" | |
| 13 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | |
| 14 #include "gpu/command_buffer/service/gpu_scheduler.h" | |
| 15 #include "ui/gfx/native_widget_types.h" | |
| 16 #include "ui/gl/gl_context.h" | |
| 17 #include "ui/gl/gl_context.h" | |
| 18 #include "ui/gl/gl_surface.h" | |
| 19 #include "ui/gl/gl_surface.h" | |
| 20 #include <EGL/egl.h> | |
| 21 | |
| 22 namespace gpu { | |
| 23 class CommandBufferService; | |
| 24 class GpuControl; | |
| 25 class GpuScheduler; | |
| 26 class TransferBuffer; | |
| 27 class TransferBufferManagerInterface; | |
| 28 | |
| 29 namespace gles2 { | |
| 30 class GLES2CmdHelper; | |
| 31 class GLES2Interface; | |
| 32 } // namespace gles2 | |
| 33 } // namespace gpu | |
| 34 | |
| 35 namespace egl { | |
| 36 class Display; | |
| 37 class Surface; | |
| 38 class Config; | |
| 39 | |
| 40 class Context : public base::RefCountedThreadSafe<Context>, | |
| 41 private gpu::GpuControl { | |
| 42 public: | |
| 43 Context(Display* display, const Config* config); | |
| 44 bool is_current_in_some_thread() const { return is_current_in_some_thread_; } | |
| 45 void set_is_current_in_some_thread(bool flag) { | |
| 46 is_current_in_some_thread_ = flag; | |
| 47 } | |
| 48 void MarkDestroyed(); | |
| 49 void FlushAndSwapBuffers(gfx::GLSurface* current_surface); | |
| 50 | |
| 51 static bool MakeCurrent(Context* current_context, | |
| 52 gfx::GLSurface* current_surface, | |
| 53 Context* new_context, | |
| 54 gfx::GLSurface* new_surface); | |
| 55 | |
| 56 static bool ValidateAttributeList(const EGLint* attrib_list); | |
| 57 | |
| 58 // GpuControl implementation. | |
| 59 gpu::Capabilities GetCapabilities() override; | |
| 60 int32_t CreateImage(ClientBuffer buffer, | |
| 61 size_t width, | |
| 62 size_t height, | |
| 63 unsigned internalformat) override; | |
| 64 void DestroyImage(int32_t id) override; | |
| 65 int32_t CreateGpuMemoryBufferImage(size_t width, | |
| 66 size_t height, | |
| 67 unsigned internalformat, | |
| 68 unsigned usage) override; | |
| 69 void SignalQuery(uint32_t query, const base::Closure& callback) override; | |
| 70 void SetLock(base::Lock*) override; | |
| 71 bool IsGpuChannelLost() override; | |
| 72 void EnsureWorkVisible() override; | |
| 73 gpu::CommandBufferNamespace GetNamespaceID() const override; | |
| 74 gpu::CommandBufferId GetCommandBufferID() const override; | |
| 75 int32_t GetExtraCommandBufferData() const override; | |
| 76 uint64_t GenerateFenceSyncRelease() override; | |
| 77 bool IsFenceSyncRelease(uint64_t release) override; | |
| 78 bool IsFenceSyncFlushed(uint64_t release) override; | |
| 79 bool IsFenceSyncFlushReceived(uint64_t release) override; | |
| 80 void SignalSyncToken(const gpu::SyncToken& sync_token, | |
| 81 const base::Closure& callback) override; | |
| 82 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; | |
| 83 | |
| 84 // Called by ThreadState to set the needed global variables when this context | |
| 85 // is current. | |
| 86 void ApplyCurrentContext(gfx::GLSurface* current_surface); | |
| 87 static void ApplyContextReleased(); | |
| 88 | |
| 89 private: | |
| 90 friend class base::RefCountedThreadSafe<Context>; | |
| 91 ~Context() override; | |
| 92 bool CreateService(gfx::GLSurface* gl_surface); | |
| 93 void DestroyService(); | |
| 94 // Returns true if the object has GL service, either a working one or one | |
| 95 // that has lost its GL context. | |
| 96 bool HasService() const; | |
| 97 void MarkServiceContextLost(); | |
| 98 bool WasServiceContextLost() const; | |
| 99 bool IsCompatibleSurface(gfx::GLSurface* gl_surface); | |
| 100 bool Flush(gfx::GLSurface* gl_surface); | |
| 101 | |
| 102 Display* display_; | |
| 103 const Config* config_; | |
| 104 bool is_current_in_some_thread_; | |
| 105 bool is_destroyed_; | |
| 106 scoped_ptr<gpu::CommandBufferService> command_buffer_; | |
| 107 scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; | |
| 108 scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; | |
| 109 scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; | |
| 110 scoped_ptr<gpu::TransferBuffer> transfer_buffer_; | |
| 111 | |
| 112 scoped_refptr<gfx::GLContext> gl_context_; | |
| 113 | |
| 114 scoped_ptr<gpu::gles2::GLES2Interface> client_gl_context_; | |
| 115 DISALLOW_COPY_AND_ASSIGN(Context); | |
| 116 }; | |
| 117 | |
| 118 } // namespace egl | |
| 119 | |
| 120 #endif // GPU_GLES2_CONFORM_TEST_CONTEXT_H_ | |
| OLD | NEW |