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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" | 7 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
8 | 8 |
9 #include "third_party/khronos/GLES2/gl2.h" | 9 #include "third_party/khronos/GLES2/gl2.h" |
10 #ifndef GL_GLEXT_PROTOTYPES | 10 #ifndef GL_GLEXT_PROTOTYPES |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 context_->Echo(base::Bind( | 316 context_->Echo(base::Bind( |
317 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, | 317 &WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete, |
318 weak_ptr_factory_.GetWeakPtr())); | 318 weak_ptr_factory_.GetWeakPtr())); |
319 } | 319 } |
320 | 320 |
321 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { | 321 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { |
322 cached_width_ = width; | 322 cached_width_ = width; |
323 cached_height_ = height; | 323 cached_height_ = height; |
324 | 324 |
325 gl_->ResizeCHROMIUM(width, height); | 325 gl_->ResizeCHROMIUM(width, height); |
326 | |
327 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | |
328 scanline_.reset(new uint8[width * 4]); | |
329 #endif // FLIP_FRAMEBUFFER_VERTICALLY | |
330 } | 326 } |
331 | 327 |
332 #ifdef FLIP_FRAMEBUFFER_VERTICALLY | 328 #ifdef FLIP_FRAMEBUFFER_VERTICALLY |
333 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( | 329 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( |
334 uint8* framebuffer, | 330 uint8* framebuffer, |
335 unsigned int width, | 331 unsigned int width, |
336 unsigned int height) { | 332 unsigned int height) { |
337 uint8* scanline = scanline_.get(); | 333 if (width == 0) |
338 if (!scanline) | |
339 return; | 334 return; |
| 335 scanline_.resize(width * 4); |
| 336 uint8* scanline = &scanline_[0]; |
340 unsigned int row_bytes = width * 4; | 337 unsigned int row_bytes = width * 4; |
341 unsigned int count = height / 2; | 338 unsigned int count = height / 2; |
342 for (unsigned int i = 0; i < count; i++) { | 339 for (unsigned int i = 0; i < count; i++) { |
343 uint8* row_a = framebuffer + i * row_bytes; | 340 uint8* row_a = framebuffer + i * row_bytes; |
344 uint8* row_b = framebuffer + (height - i - 1) * row_bytes; | 341 uint8* row_b = framebuffer + (height - i - 1) * row_bytes; |
345 // TODO(kbr): this is where the multiplication of the alpha | 342 // TODO(kbr): this is where the multiplication of the alpha |
346 // channel into the color buffer will need to occur if the | 343 // channel into the color buffer will need to occur if the |
347 // user specifies the "premultiplyAlpha" flag in the context | 344 // user specifies the "premultiplyAlpha" flag in the context |
348 // creation attributes. | 345 // creation attributes. |
349 memcpy(scanline, row_b, row_bytes); | 346 memcpy(scanline, row_b, row_bytes); |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 } | 1184 } |
1188 if (attributes_.shareResources) | 1185 if (attributes_.shareResources) |
1189 ClearSharedContexts(); | 1186 ClearSharedContexts(); |
1190 RenderViewImpl* renderview = | 1187 RenderViewImpl* renderview = |
1191 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; | 1188 web_view_ ? RenderViewImpl::FromWebView(web_view_) : NULL; |
1192 if (renderview) | 1189 if (renderview) |
1193 renderview->OnViewContextSwapBuffersAborted(); | 1190 renderview->OnViewContextSwapBuffersAborted(); |
1194 } | 1191 } |
1195 | 1192 |
1196 #endif // defined(ENABLE_GPU) | 1193 #endif // defined(ENABLE_GPU) |
OLD | NEW |