Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 12896006: mac: Clean up a few more uses of USE_SKIA (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mac Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 weak_ptr_factory_.GetWeakPtr())); 570 weak_ptr_factory_.GetWeakPtr()));
571 } 571 }
572 572
573 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) { 573 void WebGraphicsContext3DCommandBufferImpl::reshape(int width, int height) {
574 cached_width_ = width; 574 cached_width_ = width;
575 cached_height_ = height; 575 cached_height_ = height;
576 576
577 gl_->ResizeCHROMIUM(width, height); 577 gl_->ResizeCHROMIUM(width, height);
578 } 578 }
579 579
580 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
581 void WebGraphicsContext3DCommandBufferImpl::FlipVertically( 580 void WebGraphicsContext3DCommandBufferImpl::FlipVertically(
582 uint8* framebuffer, 581 uint8* framebuffer,
583 unsigned int width, 582 unsigned int width,
584 unsigned int height) { 583 unsigned int height) {
585 if (width == 0) 584 if (width == 0)
586 return; 585 return;
587 scanline_.resize(width * 4); 586 scanline_.resize(width * 4);
588 uint8* scanline = &scanline_[0]; 587 uint8* scanline = &scanline_[0];
589 unsigned int row_bytes = width * 4; 588 unsigned int row_bytes = width * 4;
590 unsigned int count = height / 2; 589 unsigned int count = height / 2;
591 for (unsigned int i = 0; i < count; i++) { 590 for (unsigned int i = 0; i < count; i++) {
592 uint8* row_a = framebuffer + i * row_bytes; 591 uint8* row_a = framebuffer + i * row_bytes;
593 uint8* row_b = framebuffer + (height - i - 1) * row_bytes; 592 uint8* row_b = framebuffer + (height - i - 1) * row_bytes;
594 // TODO(kbr): this is where the multiplication of the alpha 593 // TODO(kbr): this is where the multiplication of the alpha
595 // channel into the color buffer will need to occur if the 594 // channel into the color buffer will need to occur if the
596 // user specifies the "premultiplyAlpha" flag in the context 595 // user specifies the "premultiplyAlpha" flag in the context
597 // creation attributes. 596 // creation attributes.
598 memcpy(scanline, row_b, row_bytes); 597 memcpy(scanline, row_b, row_bytes);
599 memcpy(row_b, row_a, row_bytes); 598 memcpy(row_b, row_a, row_bytes);
600 memcpy(row_a, scanline, row_bytes); 599 memcpy(row_a, scanline, row_bytes);
601 } 600 }
602 } 601 }
603 #endif
604 602
605 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer( 603 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer(
606 unsigned char* pixels, 604 unsigned char* pixels,
607 size_t buffer_size, 605 size_t buffer_size,
608 WebGLId buffer, 606 WebGLId buffer,
609 int width, 607 int width,
610 int height) { 608 int height) {
611 if (buffer_size != static_cast<size_t>(4 * width * height)) { 609 if (buffer_size != static_cast<size_t>(4 * width * height)) {
612 return false; 610 return false;
613 } 611 }
(...skipping 16 matching lines...) Expand all
630 // TODO(kbr): expose GL_BGRA as extension. 628 // TODO(kbr): expose GL_BGRA as extension.
631 for (size_t i = 0; i < buffer_size; i += 4) { 629 for (size_t i = 0; i < buffer_size; i += 4) {
632 std::swap(pixels[i], pixels[i + 2]); 630 std::swap(pixels[i], pixels[i + 2]);
633 } 631 }
634 #endif 632 #endif
635 633
636 if (mustRestoreFBO) { 634 if (mustRestoreFBO) {
637 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_); 635 gl_->BindFramebuffer(GL_FRAMEBUFFER, bound_fbo_);
638 } 636 }
639 637
640 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
641 if (pixels) { 638 if (pixels) {
642 FlipVertically(pixels, width, height); 639 FlipVertically(pixels, width, height);
643 } 640 }
644 #endif
645 641
646 return true; 642 return true;
647 } 643 }
648 644
649 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer( 645 bool WebGraphicsContext3DCommandBufferImpl::readBackFramebuffer(
650 unsigned char* pixels, 646 unsigned char* pixels,
651 size_t buffer_size) { 647 size_t buffer_size) {
652 return readBackFramebuffer(pixels, buffer_size, 0, width(), height()); 648 return readBackFramebuffer(pixels, buffer_size, 0, width(), height());
653 } 649 }
654 650
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 1744
1749 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage( 1745 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(
1750 const std::string& message, int id) { 1746 const std::string& message, int id) {
1751 if (error_message_callback_) { 1747 if (error_message_callback_) {
1752 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str()); 1748 WebKit::WebString str = WebKit::WebString::fromUTF8(message.c_str());
1753 error_message_callback_->onErrorMessage(str, id); 1749 error_message_callback_->onErrorMessage(str, id);
1754 } 1750 }
1755 } 1751 }
1756 1752
1757 } // namespace content 1753 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h ('k') | printing/metafile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698