OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 context_->Echo(base::Bind( | 306 context_->Echo(base::Bind( |
307 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 307 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
308 weak_ptr_factory_.GetWeakPtr())); | 308 weak_ptr_factory_.GetWeakPtr())); |
309 } | 309 } |
310 | 310 |
311 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { | 311 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { |
312 cached_width_ = width; | 312 cached_width_ = width; |
313 cached_height_ = height; | 313 cached_height_ = height; |
314 | 314 |
315 gl_->ResizeCHROMIUM(width, height); | 315 gl_->ResizeCHROMIUM(width, height); |
316 | |
317 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | |
318 scanline_.reset(new uint8[width * 4]); | |
319 #endif // FLIP_FRAMEBUFFER_VERTICALLY | |
320 } | 316 } |
321 | 317 |
322 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 318 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
323 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( | 319 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( |
324 uint8* framebuffer, | 320 uint8* framebuffer, |
325 unsigned int width, | 321 unsigned int width, |
326 unsigned int height) { | 322 unsigned int height) { |
327 uint8* scanline = scanline_.get(); | 323 if (width == 0) |
328 if (!scanline) | |
329 return; | 324 return; |
| 325 scanline_.resize(width * 4); |
| 326 uint8* scanline = &scanline_[0]; |
330 unsigned int row_bytes = width * 4; | 327 unsigned int row_bytes = width * 4; |
331 unsigned int count = height / 2; | 328 unsigned int count = height / 2; |
332 for (unsigned int i = 0; i < count; i++) { | 329 for (unsigned int i = 0; i < count; i++) { |
333 uint8* row_a = framebuffer + i * row_bytes; | 330 uint8* row_a = framebuffer + i * row_bytes; |
334 uint8* row_b = framebuffer + (height - i - 1) * row_bytes; | 331 uint8* row_b = framebuffer + (height - i - 1) * row_bytes; |
335 // TODO(kbr): this is where the multiplication of the alpha | 332 // TODO(kbr): this is where the multiplication of the alpha |
336 // channel into the color buffer will need to occur if the | 333 // channel into the color buffer will need to occur if the |
337 // user specifies the "premultiplyAlpha" flag in the context | 334 // user specifies the "premultiplyAlpha" flag in the context |
338 // creation attributes. | 335 // creation attributes. |
339 memcpy(scanline, row_b, row_bytes); | 336 memcpy(scanline, row_b, row_bytes); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 } | 1207 } |
1211 | 1208 |
1212 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( | 1209 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( |
1213 const std::string& message, int id) { | 1210 const std::string& message, int id) { |
1214 if (error_message_callback_) { | 1211 if (error_message_callback_) { |
1215 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); | 1212 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); |
1216 error_message_callback_->onErrorMessage(str, id); | 1213 error_message_callback_->onErrorMessage(str, id); |
1217 } | 1214 } |
1218 } | 1215 } |
1219 | 1216 |
OLD | NEW |