Index: gpu/gles2_conform_support/egl/context.h |
diff --git a/gpu/gles2_conform_support/egl/display.h b/gpu/gles2_conform_support/egl/context.h |
similarity index 52% |
copy from gpu/gles2_conform_support/egl/display.h |
copy to gpu/gles2_conform_support/egl/context.h |
index e3a57bcb49671113e2cad34ad4885ba0d4cca910..2bfc4591080377680fbe8a29343af501fc849843 100644 |
--- a/gpu/gles2_conform_support/egl/display.h |
+++ b/gpu/gles2_conform_support/egl/context.h |
@@ -1,16 +1,12 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 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 GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ |
-#define GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ |
- |
-#include <EGL/egl.h> |
-#include <stddef.h> |
-#include <stdint.h> |
+#ifndef GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |
+#define GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |
#include "base/macros.h" |
-#include "base/memory/scoped_ptr.h" |
+#include "base/memory/ref_counted.h" |
#include "gpu/command_buffer/client/gles2_cmd_helper.h" |
#include "gpu/command_buffer/client/gpu_control.h" |
#include "gpu/command_buffer/service/command_buffer_service.h" |
@@ -18,7 +14,10 @@ |
#include "gpu/command_buffer/service/gpu_scheduler.h" |
#include "ui/gfx/native_widget_types.h" |
#include "ui/gl/gl_context.h" |
+#include "ui/gl/gl_context.h" |
#include "ui/gl/gl_surface.h" |
+#include "ui/gl/gl_surface.h" |
+#include <EGL/egl.h> |
namespace gpu { |
class CommandBufferService; |
@@ -29,52 +28,29 @@ class TransferBufferManagerInterface; |
namespace gles2 { |
class GLES2CmdHelper; |
-class GLES2Implementation; |
+class GLES2Interface; |
} // namespace gles2 |
} // namespace gpu |
namespace egl { |
- |
-class Config; |
+class Display; |
class Surface; |
+class Config; |
-class Display : private gpu::GpuControl { |
+class Context : public base::RefCountedThreadSafe<Context>, |
+ private gpu::GpuControl { |
public: |
- explicit Display(EGLNativeDisplayType display_id); |
- ~Display() override; |
- |
- void SetCreateOffscreen(int width, int height) { |
- create_offscreen_ = true; |
- create_offscreen_width_ = width; |
- create_offscreen_height_ = height; |
- } |
- |
- bool is_initialized() const { return is_initialized_; } |
- bool Initialize(); |
- |
- // Config routines. |
- bool IsValidConfig(EGLConfig config); |
- bool ChooseConfigs( |
- EGLConfig* configs, EGLint config_size, EGLint* num_config); |
- bool GetConfigs(EGLConfig* configs, EGLint config_size, EGLint* num_config); |
- bool GetConfigAttrib(EGLConfig config, EGLint attribute, EGLint* value); |
- |
- // Surface routines. |
- bool IsValidNativeWindow(EGLNativeWindowType win); |
- bool IsValidSurface(EGLSurface surface); |
- EGLSurface CreateWindowSurface(EGLConfig config, |
- EGLNativeWindowType win, |
- const EGLint* attrib_list); |
- void DestroySurface(EGLSurface surface); |
- void SwapBuffers(EGLSurface surface); |
- |
- // Context routines. |
- bool IsValidContext(EGLContext ctx); |
- EGLContext CreateContext(EGLConfig config, |
- EGLContext share_ctx, |
- const EGLint* attrib_list); |
- void DestroyContext(EGLContext ctx); |
- bool MakeCurrent(EGLSurface draw, EGLSurface read, EGLContext ctx); |
+ Context(Display* display, const Config* config); |
+ bool is_current_in_some_thread() const { return is_current_in_some_thread_; } |
+ void SetDestroyed(Surface* current_surface_if_own); |
+ void FlushAndSwapBuffers(Surface* current_surface); |
+ void MakeCurrentRelease(Surface* current_surface); |
+ bool MakeCurrentSwitchSurface(Surface* current_surface, Surface* new_surface); |
+ bool MakeCurrent(Surface* new_surface); |
+ gfx::GLContext* gl_context() const; |
+ gpu::gles2::GLES2Interface* client_gl_context() const; |
+ |
+ static bool ValidateAttributeList(const EGLint* attrib_list); |
// GpuControl implementation. |
gpu::Capabilities GetCapabilities() override; |
@@ -103,32 +79,28 @@ class Display : private gpu::GpuControl { |
bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
private: |
- EGLNativeDisplayType display_id_; |
- |
- bool is_initialized_; |
- |
- bool create_offscreen_; |
- int create_offscreen_width_; |
- int create_offscreen_height_; |
- uint64_t next_fence_sync_release_; |
- |
- scoped_refptr<gpu::TransferBufferManagerInterface> transfer_buffer_manager_; |
+ friend class base::RefCountedThreadSafe<Context>; |
+ ~Context() override; |
+ void Cleanup(); |
+ void MarkContextLost(); |
+ bool WasContextLost() const; |
+ bool IsCompatibleSurface(gfx::GLSurface* gl_surface); |
+ |
+ Display* display_; |
+ const Config* config_; |
+ bool is_current_in_some_thread_; |
scoped_ptr<gpu::CommandBufferService> command_buffer_; |
- scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; |
- scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
- scoped_refptr<gfx::GLContext> gl_context_; |
- scoped_refptr<gfx::GLSurface> gl_surface_; |
scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; |
+ scoped_ptr<gpu::gles2::GLES2Decoder> decoder_; |
+ scoped_ptr<gpu::GpuScheduler> gpu_scheduler_; |
scoped_ptr<gpu::TransferBuffer> transfer_buffer_; |
- // TODO(alokp): Support more than one config, surface, and context. |
- scoped_ptr<Config> config_; |
- scoped_ptr<Surface> surface_; |
- scoped_ptr<gpu::gles2::GLES2Implementation> context_; |
+ scoped_refptr<gfx::GLContext> gl_context_; |
- DISALLOW_COPY_AND_ASSIGN(Display); |
+ scoped_ptr<gpu::gles2::GLES2Interface> client_gl_context_; |
+ DISALLOW_COPY_AND_ASSIGN(Context); |
}; |
} // namespace egl |
-#endif // GPU_GLES2_CONFORM_SUPPORT_EGL_DISPLAY_H_ |
+#endif // GPU_GLES2_CONFORM_TEST_CONTEXT_H_ |