blob: 5a5cdbd1fcacc165bc1ea17a55f163ed3bb1c02b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2012 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.
#include "gpu/blink/webgraphicscontext3d_impl.h"
#include <stdint.h>
#include "base/atomicops.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/sys_info.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
#include "third_party/khronos/GLES2/gl2.h"
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES 1
#endif
#include "third_party/khronos/GLES2/gl2ext.h"
namespace gpu_blink {
class WebGraphicsContext3DErrorMessageCallback
: public ::gpu::gles2::GLES2ImplementationErrorMessageCallback {
public:
WebGraphicsContext3DErrorMessageCallback(
WebGraphicsContext3DImpl* context)
: graphics_context_(context) {
}
void OnErrorMessage(const char* msg, int id) override;
private:
WebGraphicsContext3DImpl* graphics_context_;
DISALLOW_COPY_AND_ASSIGN(WebGraphicsContext3DErrorMessageCallback);
};
void WebGraphicsContext3DErrorMessageCallback::OnErrorMessage(
const char* msg, int id) {
graphics_context_->OnErrorMessage(msg, id);
}
WebGraphicsContext3DImpl::WebGraphicsContext3DImpl()
: initialized_(false),
initialize_failed_(false),
context_lost_callback_(0),
error_message_callback_(0),
gl_(NULL) {}
WebGraphicsContext3DImpl::~WebGraphicsContext3DImpl() {
}
void WebGraphicsContext3DImpl::setErrorMessageCallback(
WebGraphicsContext3D::WebGraphicsErrorMessageCallback* cb) {
error_message_callback_ = cb;
}
void WebGraphicsContext3DImpl::setContextLostCallback(
WebGraphicsContext3D::WebGraphicsContextLostCallback* cb) {
context_lost_callback_ = cb;
}
::gpu::gles2::GLES2ImplementationErrorMessageCallback*
WebGraphicsContext3DImpl::getErrorMessageCallback() {
if (!client_error_message_callback_) {
client_error_message_callback_.reset(
new WebGraphicsContext3DErrorMessageCallback(this));
}
return client_error_message_callback_.get();
}
void WebGraphicsContext3DImpl::OnErrorMessage(
const std::string& message, int id) {
if (error_message_callback_) {
blink::WebString str = blink::WebString::fromUTF8(message.c_str());
error_message_callback_->onErrorMessage(str, id);
}
}
} // namespace gpu_blink
|