summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gl_context_virtual.cc18
-rw-r--r--gpu/command_buffer/service/gl_context_virtual.h7
-rw-r--r--gpu/command_buffer/service/gl_state_restorer_impl.cc6
-rw-r--r--gpu/command_buffer/service/gl_state_restorer_impl.h6
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc7
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h5
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc3
7 files changed, 31 insertions, 21 deletions
diff --git a/gpu/command_buffer/service/gl_context_virtual.cc b/gpu/command_buffer/service/gl_context_virtual.cc
index 293dfa5..4145d3a 100644
--- a/gpu/command_buffer/service/gl_context_virtual.cc
+++ b/gpu/command_buffer/service/gl_context_virtual.cc
@@ -12,11 +12,12 @@ namespace gpu {
GLContextVirtual::GLContextVirtual(
gfx::GLShareGroup* share_group,
gfx::GLContext* shared_context,
- gles2::GLES2Decoder* decoder)
+ base::WeakPtr<gles2::GLES2Decoder> decoder)
: GLContext(share_group),
shared_context_(shared_context),
display_(NULL),
- state_restorer_(new GLStateRestorerImpl(decoder)) {
+ state_restorer_(new GLStateRestorerImpl(decoder)),
+ decoder_(decoder) {
shared_context_->SetupForVirtualization();
}
@@ -28,20 +29,27 @@ bool GLContextVirtual::Initialize(
gfx::GLSurface* compatible_surface, gfx::GpuPreference gpu_preference) {
display_ = static_cast<gfx::Display*>(compatible_surface->GetDisplay());
+ if (!shared_context_->MakeCurrent(compatible_surface))
+ return false;
+
+ shared_context_->ReleaseCurrent(compatible_surface);
return true;
}
void GLContextVirtual::Destroy() {
+ shared_context_ = NULL;
+ display_ = NULL;
}
bool GLContextVirtual::MakeCurrent(gfx::GLSurface* surface) {
- shared_context_->MakeVirtuallyCurrent(this, surface);
+ if (decoder_.get())
+ shared_context_->MakeVirtuallyCurrent(this, surface);
+ else
+ shared_context_->MakeCurrent(surface);
return true;
}
void GLContextVirtual::ReleaseCurrent(gfx::GLSurface* surface) {
- shared_context_ = NULL;
- display_ = NULL;
}
bool GLContextVirtual::IsCurrent(gfx::GLSurface* surface) {
diff --git a/gpu/command_buffer/service/gl_context_virtual.h b/gpu/command_buffer/service/gl_context_virtual.h
index 23ca76b..f906dd9 100644
--- a/gpu/command_buffer/service/gl_context_virtual.h
+++ b/gpu/command_buffer/service/gl_context_virtual.h
@@ -6,7 +6,9 @@
#define GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_VIRTUAL_H_
#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "gpu/gpu_export.h"
#include "ui/gl/gl_context.h"
@@ -27,7 +29,7 @@ class GPU_EXPORT GLContextVirtual : public gfx::GLContext {
GLContextVirtual(
gfx::GLShareGroup* share_group,
gfx::GLContext* shared_context,
- gles2::GLES2Decoder* decoder);
+ base::WeakPtr<gles2::GLES2Decoder> decoder);
gfx::Display* display();
@@ -50,9 +52,10 @@ class GPU_EXPORT GLContextVirtual : public gfx::GLContext {
virtual ~GLContextVirtual();
private:
- gfx::GLContext* shared_context_;
+ scoped_refptr<gfx::GLContext> shared_context_;
gfx::Display* display_;
scoped_ptr<gfx::GLStateRestorer> state_restorer_;
+ base::WeakPtr<gles2::GLES2Decoder> decoder_;
DISALLOW_COPY_AND_ASSIGN(GLContextVirtual);
};
diff --git a/gpu/command_buffer/service/gl_state_restorer_impl.cc b/gpu/command_buffer/service/gl_state_restorer_impl.cc
index 486d95b..0290c9a 100644
--- a/gpu/command_buffer/service/gl_state_restorer_impl.cc
+++ b/gpu/command_buffer/service/gl_state_restorer_impl.cc
@@ -8,7 +8,8 @@
namespace gpu {
-GLStateRestorerImpl::GLStateRestorerImpl(gles2::GLES2Decoder* decoder)
+GLStateRestorerImpl::GLStateRestorerImpl(
+ base::WeakPtr<gles2::GLES2Decoder> decoder)
: decoder_(decoder) {
}
@@ -16,9 +17,8 @@ GLStateRestorerImpl::~GLStateRestorerImpl() {
}
void GLStateRestorerImpl::RestoreState() {
+ DCHECK(decoder_.get());
decoder_->RestoreState();
}
} // namespace gpu
-
-
diff --git a/gpu/command_buffer/service/gl_state_restorer_impl.h b/gpu/command_buffer/service/gl_state_restorer_impl.h
index 04d80956..b210ac0 100644
--- a/gpu/command_buffer/service/gl_state_restorer_impl.h
+++ b/gpu/command_buffer/service/gl_state_restorer_impl.h
@@ -8,6 +8,7 @@
#define GPU_COMMAND_BUFFER_SERVICE_GL_STATE_RESTORER_IMPL_H_
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "gpu/gpu_export.h"
#include "ui/gl/gl_state_restorer.h"
@@ -19,13 +20,13 @@ class GLES2Decoder;
// This class implements a GLStateRestorer that forwards to a GLES2Decoder.
class GPU_EXPORT GLStateRestorerImpl : public gfx::GLStateRestorer {
public:
- explicit GLStateRestorerImpl(gles2::GLES2Decoder* decoder);
+ explicit GLStateRestorerImpl(base::WeakPtr<gles2::GLES2Decoder> decoder);
virtual ~GLStateRestorerImpl();
virtual void RestoreState() OVERRIDE;
private:
- gles2::GLES2Decoder* decoder_;
+ base::WeakPtr<gles2::GLES2Decoder> decoder_;
DISALLOW_COPY_AND_ASSIGN(GLStateRestorerImpl);
};
@@ -33,4 +34,3 @@ class GPU_EXPORT GLStateRestorerImpl : public gfx::GLStateRestorer {
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_GL_STATE_RESTORER_IMPL_H_
-
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 406f728..50d2ca0 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -22,7 +22,6 @@
#include "base/mac/scoped_cftyperef.h"
#endif
#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
#include "base/string_number_conversions.h"
#include "build/build_config.h"
#define GLES2_GPU_SERVICE 1
@@ -56,7 +55,6 @@
#include "gpu/command_buffer/service/texture_manager.h"
#include "gpu/command_buffer/service/vertex_attrib_manager.h"
#include "gpu/command_buffer/service/vertex_array_manager.h"
-#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
@@ -489,8 +487,7 @@ bool GLES2Decoder::IsAngle() {
// This class implements GLES2Decoder so we don't have to expose all the GLES2
// cmd stuff to outside this class.
-class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
- public GLES2Decoder {
+class GLES2DecoderImpl : public GLES2Decoder {
public:
static const int kMaxLogMessages = 256;
@@ -2967,7 +2964,7 @@ bool GLES2DecoderImpl::SetParent(GLES2Decoder* new_parent,
new_parent_impl->texture_manager()->
SetInfoTarget(offscreen_saved_color_texture_info_, GL_TEXTURE_2D);
- parent_ = new_parent_impl->AsWeakPtr();
+ parent_ = base::AsWeakPtr<GLES2DecoderImpl>(new_parent_impl);
UpdateParentTextureInfo();
} else {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 160a301..9b089e3 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -10,10 +10,12 @@
#include <vector>
#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
#include "base/time.h"
#include "build/build_config.h"
#include "gpu/command_buffer/service/common_decoder.h"
#include "ui/gfx/size.h"
+#include "ui/gl/gl_context.h"
namespace gfx {
class GLContext;
@@ -45,7 +47,8 @@ struct DisallowedFeatures {
// This class implements the AsyncAPIInterface interface, decoding GLES2
// commands and calling GL.
-class GPU_EXPORT GLES2Decoder : public CommonDecoder {
+class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>,
+ public CommonDecoder {
public:
typedef error::Error Error;
typedef base::Callback<void(int32 id, const std::string& msg)> MsgCallback;
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index 3b0dee7..6ec3097 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -125,7 +125,7 @@ void GLManager::Initialize(const GLManager::Options& options) {
if (real_gl_context) {
context_ = scoped_refptr<gfx::GLContext>(new gpu::GLContextVirtual(
- share_group_.get(), real_gl_context, decoder_.get()));
+ share_group_.get(), real_gl_context, decoder_->AsWeakPtr()));
ASSERT_TRUE(context_->Initialize(
surface_.get(), gfx::PreferIntegratedGpu));
} else {
@@ -206,4 +206,3 @@ bool GLManager::GetBufferChanged(int32 transfer_buffer_id) {
}
} // namespace gpu
-