Commit 0c652b8e authored by gman@chromium.org's avatar gman@chromium.org

Plumb client side synthesized GL messages to JS Console

TEST=tested by hand
BUG=none

R=apatrick@chromium.org


Review URL: http://codereview.chromium.org/9706042

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126869 0039d316-1c4b-4281-b951-d872f2087c98
parent 86fda590
......@@ -44,6 +44,26 @@ void ClearSharedContexts() {
} // namespace anonymous
class WebGraphicsContext3DErrorMessageCallback
: public gpu::gles2::GLES2Implementation::ErrorMessageCallback {
public:
WebGraphicsContext3DErrorMessageCallback(
WebGraphicsContext3DCommandBufferImpl* context)
: context_(context) {
}
virtual void OnErrorMessage(const char* msg, int id) OVERRIDE;
private:
WebGraphicsContext3DCommandBufferImpl* context_;
DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback);
};
void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
const char* msg, int id) {
context_->OnErrorMessage(msg, id);
}
WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
int surface_id,
......@@ -72,6 +92,10 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl(
WebGraphicsContext3DCommandBufferImpl::
~WebGraphicsContext3DCommandBufferImpl() {
if (gl_) {
gl_->SetErrorMessageCallback(NULL);
}
if (host_) {
if (host_->WillGpuSwitchOccur(false, gpu_preference_)) {
host_->ForciblyCloseChannel();
......@@ -203,6 +227,10 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() {
base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage,
weak_ptr_factory_.GetWeakPtr()));
client_error_message_callback_.reset(
new WebGraphicsContext3DErrorMessageCallback(this));
gl_->SetErrorMessageCallback(client_error_message_callback_.get());
// TODO(gman): Remove this.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisableGLSLTranslator)) {
......
......@@ -56,6 +56,8 @@ class WebGraphicsContext3DSwapBuffersClient {
virtual void OnViewContextSwapBuffersAborted() = 0;
};
class WebGraphicsContext3DErrorMessageCallback;
class WebGraphicsContext3DCommandBufferImpl
: public WebKit::WebGraphicsContext3D {
public:
......@@ -501,6 +503,8 @@ class WebGraphicsContext3DCommandBufferImpl
#endif
private:
friend class WebGraphicsContext3DErrorMessageCallback;
// Initialize the underlying GL context. May be called multiple times; second
// and subsequent calls are ignored. Must be called from the thread that is
// going to use this object to issue GL commands (which might not be the main
......@@ -543,6 +547,8 @@ class WebGraphicsContext3DCommandBufferImpl
WebGraphicsContext3D::WebGraphicsErrorMessageCallback*
error_message_callback_;
scoped_ptr<WebGraphicsContext3DErrorMessageCallback>
client_error_message_callback_;
WebGraphicsContext3D::WebGraphicsSwapBuffersCompleteCallbackCHROMIUM*
swapbuffers_complete_callback_;
......
......@@ -607,7 +607,8 @@ GLES2Implementation::GLES2Implementation(
sharing_resources_(share_resources),
bind_generates_resource_(bind_generates_resource),
use_count_(0),
current_query_(NULL) {
current_query_(NULL),
error_message_callback_(NULL) {
GPU_DCHECK(helper);
GPU_DCHECK(transfer_buffer);
GPU_CLIENT_LOG_CODE_BLOCK({
......@@ -829,6 +830,10 @@ void GLES2Implementation::SetGLError(GLenum error, const char* msg) {
if (msg) {
last_error_ = msg;
}
if (error_message_callback_) {
std::string temp(GLES2Util::GetStringError(error) + " : " + msg);
error_message_callback_->OnErrorMessage(temp.c_str(), 0);
}
error_bits_ |= GLES2Util::GLErrorToErrorBit(error);
}
......
......@@ -108,6 +108,12 @@ class IdHandlerInterface {
// shared memory and synchronization issues.
class GLES2_IMPL_EXPORT GLES2Implementation {
public:
class ErrorMessageCallback {
public:
virtual ~ErrorMessageCallback() { }
virtual void OnErrorMessage(const char* msg, int id) = 0;
};
// Stores client side cached GL state.
struct GLState {
GLState()
......@@ -215,6 +221,10 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
void FreeUnusedSharedMemory();
void FreeEverything();
void SetErrorMessageCallback(ErrorMessageCallback* callback) {
error_message_callback_ = callback;
}
private:
friend class ClientSideBufferHelper;
friend class GLES2ImplementationTest;
......@@ -522,6 +532,8 @@ class GLES2_IMPL_EXPORT GLES2Implementation {
scoped_ptr<QueryTracker> query_tracker_;
QueryTracker::Query* current_query_;
ErrorMessageCallback* error_message_callback_;
DISALLOW_COPY_AND_ASSIGN(GLES2Implementation);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment