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 53% |
copy from gpu/gles2_conform_support/egl/display.h |
copy to gpu/gles2_conform_support/egl/context.h |
index bb7700179ae4a60b9f2c4b171d1ac0982ea91c6e..a5facf22dc5a9f3691afc0c8e3663ecf5598ee35 100644 |
--- a/gpu/gles2_conform_support/egl/display.h |
+++ b/gpu/gles2_conform_support/egl/context.h |
@@ -1,17 +1,14 @@ |
-// 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 <memory> |
#include "base/macros.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" |
@@ -21,63 +18,43 @@ |
#include "gpu/config/gpu_driver_bug_workarounds.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; |
-class GpuControl; |
-class CommandExecutor; |
class TransferBuffer; |
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; |
+ Context(Display* display, const Config* config); |
+ bool is_current_in_some_thread() const { return is_current_in_some_thread_; } |
+ void set_is_current_in_some_thread(bool flag) { |
+ is_current_in_some_thread_ = flag; |
} |
+ void MarkDestroyed(); |
+ bool SwapBuffers(Surface* current_surface); |
- 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); |
+ static bool MakeCurrent(Context* current_context, |
+ Surface* current_surface, |
+ Context* new_context, |
+ Surface* new_surface); |
+ |
+ static bool ValidateAttributeList(const EGLint* attrib_list); |
// GpuControl implementation. |
void SetGpuControlClient(gpu::GpuControlClient*) override; |
@@ -105,35 +82,42 @@ class Display : private gpu::GpuControl { |
const base::Closure& callback) override; |
bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
- private: |
- EGLNativeDisplayType display_id_; |
+ // Called by ThreadState to set the needed global variables when this context |
+ // is current. |
+ void ApplyCurrentContext(gfx::GLSurface* current_surface); |
+ static void ApplyContextReleased(); |
+ private: |
+ friend class base::RefCountedThreadSafe<Context>; |
+ ~Context() override; |
+ bool CreateService(gfx::GLSurface* gl_surface); |
+ void DestroyService(); |
+ // Returns true if the object has GL service, either a working one or one |
+ // that has lost its GL context. |
+ bool HasService() const; |
+ void MarkServiceContextLost(); |
+ bool WasServiceContextLost() const; |
+ bool IsCompatibleSurface(Surface* surface) const; |
+ bool Flush(gfx::GLSurface* gl_surface); |
+ |
+ Display* display_; |
+ const Config* config_; |
+ bool is_current_in_some_thread_; |
+ bool is_destroyed_; |
gpu::GpuPreferences gpu_preferences_; |
const gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
- 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_; |
std::unique_ptr<gpu::CommandBufferService> command_buffer_; |
- std::unique_ptr<gpu::CommandExecutor> executor_; |
- std::unique_ptr<gpu::gles2::GLES2Decoder> decoder_; |
- scoped_refptr<gfx::GLContext> gl_context_; |
- scoped_refptr<gfx::GLSurface> gl_surface_; |
std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_cmd_helper_; |
+ std::unique_ptr<gpu::gles2::GLES2Decoder> decoder_; |
+ std::unique_ptr<gpu::CommandExecutor> command_executor_; |
std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; |
- // TODO(alokp): Support more than one config, surface, and context. |
- std::unique_ptr<Config> config_; |
- std::unique_ptr<Surface> surface_; |
- std::unique_ptr<gpu::gles2::GLES2Implementation> context_; |
+ scoped_refptr<gfx::GLContext> gl_context_; |
- DISALLOW_COPY_AND_ASSIGN(Display); |
+ std::unique_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_ |