OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. | 4 * Copyright (C) 2010 Mozilla Corporation. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 , m_initializedAvailableExtensions(false) | 86 , m_initializedAvailableExtensions(false) |
87 , m_layerComposited(false) | 87 , m_layerComposited(false) |
88 , m_preserveDrawingBuffer(false) | 88 , m_preserveDrawingBuffer(false) |
89 , m_packAlignment(4) | 89 , m_packAlignment(4) |
90 , m_grContext(0) | 90 , m_grContext(0) |
91 { | 91 { |
92 } | 92 } |
93 | 93 |
94 GraphicsContext3D::~GraphicsContext3D() | 94 GraphicsContext3D::~GraphicsContext3D() |
95 { | 95 { |
96 setContextLostCallback(nullptr); | |
97 setErrorMessageCallback(nullptr); | |
98 } | 96 } |
99 | 97 |
100 // Macros to assist in delegating from GraphicsContext3D to | 98 // Macros to assist in delegating from GraphicsContext3D to |
101 // WebGraphicsContext3D. | 99 // WebGraphicsContext3D. |
102 | 100 |
103 #define DELEGATE_TO_WEBCONTEXT(name) \ | 101 #define DELEGATE_TO_WEBCONTEXT(name) \ |
104 void GraphicsContext3D::name() \ | 102 void GraphicsContext3D::name() \ |
105 { \ | 103 { \ |
106 m_impl->name(); \ | 104 m_impl->name(); \ |
107 } | 105 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 { \ | 157 { \ |
160 m_impl->name(a1, a2, a3, a4, a5, a6, a7); \ | 158 m_impl->name(a1, a2, a3, a4, a5, a6, a7); \ |
161 } | 159 } |
162 | 160 |
163 #define DELEGATE_TO_WEBCONTEXT_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ | 161 #define DELEGATE_TO_WEBCONTEXT_9(name, t1, t2, t3, t4, t5, t6, t7, t8, t9) \ |
164 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8
a8, t9 a9) \ | 162 void GraphicsContext3D::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6, t7 a7, t8
a8, t9 a9) \ |
165 { \ | 163 { \ |
166 m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ | 164 m_impl->name(a1, a2, a3, a4, a5, a6, a7, a8, a9); \ |
167 } | 165 } |
168 | 166 |
169 class GraphicsContext3DContextLostCallbackAdapter : public blink::WebGraphicsCon
text3D::WebGraphicsContextLostCallback { | |
170 public: | |
171 GraphicsContext3DContextLostCallbackAdapter(PassOwnPtr<GraphicsContext3D::Co
ntextLostCallback> callback) | |
172 : m_contextLostCallback(callback) { } | |
173 virtual ~GraphicsContext3DContextLostCallbackAdapter() { } | |
174 | |
175 virtual void onContextLost() | |
176 { | |
177 if (m_contextLostCallback) | |
178 m_contextLostCallback->onContextLost(); | |
179 } | |
180 private: | |
181 OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback; | |
182 }; | |
183 | |
184 class GraphicsContext3DErrorMessageCallbackAdapter : public blink::WebGraphicsCo
ntext3D::WebGraphicsErrorMessageCallback { | |
185 public: | |
186 GraphicsContext3DErrorMessageCallbackAdapter(PassOwnPtr<GraphicsContext3D::E
rrorMessageCallback> callback) | |
187 : m_errorMessageCallback(callback) { } | |
188 virtual ~GraphicsContext3DErrorMessageCallbackAdapter() { } | |
189 | |
190 virtual void onErrorMessage(const blink::WebString& message, blink::WGC3Dint
id) | |
191 { | |
192 if (m_errorMessageCallback) | |
193 m_errorMessageCallback->onErrorMessage(message, id); | |
194 } | |
195 private: | |
196 OwnPtr<GraphicsContext3D::ErrorMessageCallback> m_errorMessageCallback; | |
197 }; | |
198 | |
199 void GraphicsContext3D::setContextLostCallback(PassOwnPtr<GraphicsContext3D::Con
textLostCallback> callback) | |
200 { | |
201 if (m_ownedWebContext) { | |
202 m_contextLostCallbackAdapter = adoptPtr(new GraphicsContext3DContextLost
CallbackAdapter(callback)); | |
203 m_ownedWebContext->setContextLostCallback(m_contextLostCallbackAdapter.g
et()); | |
204 } | |
205 } | |
206 | |
207 void GraphicsContext3D::setErrorMessageCallback(PassOwnPtr<GraphicsContext3D::Er
rorMessageCallback> callback) | |
208 { | |
209 if (m_ownedWebContext) { | |
210 m_errorMessageCallbackAdapter = adoptPtr(new GraphicsContext3DErrorMessa
geCallbackAdapter(callback)); | |
211 m_ownedWebContext->setErrorMessageCallback(m_errorMessageCallbackAdapter
.get()); | |
212 } | |
213 } | |
214 | |
215 PassRefPtr<GraphicsContext3D> GraphicsContext3D::createContextSupport(blink::Web
GraphicsContext3D* webContext) | 167 PassRefPtr<GraphicsContext3D> GraphicsContext3D::createContextSupport(blink::Web
GraphicsContext3D* webContext) |
216 { | 168 { |
217 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(webContex
t)); | 169 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(webContex
t)); |
218 return context.release(); | 170 return context.release(); |
219 } | 171 } |
220 | 172 |
221 // The following three creation methods are obsolete and should not be used by n
ew code. They will be removed soon. | 173 // The following three creation methods are obsolete and should not be used by n
ew code. They will be removed soon. |
222 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
butes attrs) | 174 PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
butes attrs) |
223 { | 175 { |
224 blink::WebGraphicsContext3D::Attributes webAttributes; | 176 blink::WebGraphicsContext3D::Attributes webAttributes; |
(...skipping 26 matching lines...) Expand all Loading... |
251 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(webContex
t, preserveDrawingBuffer)); | 203 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(webContex
t, preserveDrawingBuffer)); |
252 return context.release(); | 204 return context.release(); |
253 } | 205 } |
254 | 206 |
255 GrContext* GraphicsContext3D::grContext() | 207 GrContext* GraphicsContext3D::grContext() |
256 { | 208 { |
257 return m_grContext; | 209 return m_grContext; |
258 } | 210 } |
259 | 211 |
260 DELEGATE_TO_WEBCONTEXT_R(makeContextCurrent, bool) | 212 DELEGATE_TO_WEBCONTEXT_R(makeContextCurrent, bool) |
261 DELEGATE_TO_WEBCONTEXT_R(lastFlushID, uint32_t) | |
262 | 213 |
263 DELEGATE_TO_WEBCONTEXT_1(activeTexture, GLenum) | 214 DELEGATE_TO_WEBCONTEXT_1(activeTexture, GLenum) |
264 DELEGATE_TO_WEBCONTEXT_2(attachShader, Platform3DObject, Platform3DObject) | 215 DELEGATE_TO_WEBCONTEXT_2(attachShader, Platform3DObject, Platform3DObject) |
265 | 216 |
266 DELEGATE_TO_WEBCONTEXT_2(bindBuffer, GLenum, Platform3DObject) | 217 DELEGATE_TO_WEBCONTEXT_2(bindBuffer, GLenum, Platform3DObject) |
267 DELEGATE_TO_WEBCONTEXT_2(bindFramebuffer, GLenum, Platform3DObject) | 218 DELEGATE_TO_WEBCONTEXT_2(bindFramebuffer, GLenum, Platform3DObject) |
268 DELEGATE_TO_WEBCONTEXT_2(bindRenderbuffer, GLenum, Platform3DObject) | 219 DELEGATE_TO_WEBCONTEXT_2(bindRenderbuffer, GLenum, Platform3DObject) |
269 DELEGATE_TO_WEBCONTEXT_2(bindTexture, GLenum, Platform3DObject) | 220 DELEGATE_TO_WEBCONTEXT_2(bindTexture, GLenum, Platform3DObject) |
270 | 221 |
271 DELEGATE_TO_WEBCONTEXT_4(bufferData, GLenum, GLsizeiptr, const void*, GLenum) | 222 DELEGATE_TO_WEBCONTEXT_4(bufferData, GLenum, GLsizeiptr, const void*, GLenum) |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 for (unsigned i = 0; i < count; i++) { | 764 for (unsigned i = 0; i < count; i++) { |
814 uint8* rowA = framebuffer + i * rowBytes; | 765 uint8* rowA = framebuffer + i * rowBytes; |
815 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; | 766 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; |
816 memcpy(scanline, rowB, rowBytes); | 767 memcpy(scanline, rowB, rowBytes); |
817 memcpy(rowB, rowA, rowBytes); | 768 memcpy(rowB, rowA, rowBytes); |
818 memcpy(rowA, scanline, rowBytes); | 769 memcpy(rowA, scanline, rowBytes); |
819 } | 770 } |
820 } | 771 } |
821 | 772 |
822 } // namespace WebCore | 773 } // namespace WebCore |
OLD | NEW |