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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_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: Created 7 years, 9 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 "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 5 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 texture_(0), 61 texture_(0),
62 fbo_(0), 62 fbo_(0),
63 depth_stencil_buffer_(0), 63 depth_stencil_buffer_(0),
64 cached_width_(0), 64 cached_width_(0),
65 cached_height_(0), 65 cached_height_(0),
66 multisample_fbo_(0), 66 multisample_fbo_(0),
67 multisample_depth_stencil_buffer_(0), 67 multisample_depth_stencil_buffer_(0),
68 multisample_color_buffer_(0), 68 multisample_color_buffer_(0),
69 bound_fbo_(0), 69 bound_fbo_(0),
70 bound_texture_(0), 70 bound_texture_(0),
71 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
72 scanline_(0), 71 scanline_(0),
73 #endif
74 gl_context_(context), 72 gl_context_(context),
75 gl_surface_(surface), 73 gl_surface_(surface),
76 fragment_compiler_(0), 74 fragment_compiler_(0),
77 vertex_compiler_(0) { 75 vertex_compiler_(0) {
78 } 76 }
79 77
80 // All instances in a process that share resources are in the same share group. 78 // All instances in a process that share resources are in the same share group.
81 static base::LazyInstance< 79 static base::LazyInstance<
82 std::set<WebGraphicsContext3DInProcessImpl*> > 80 std::set<WebGraphicsContext3DInProcessImpl*> >
83 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER; 81 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
(...skipping 12 matching lines...) Expand all
96 if (attributes_.antialias) { 94 if (attributes_.antialias) {
97 glDeleteRenderbuffersEXT(1, &multisample_color_buffer_); 95 glDeleteRenderbuffersEXT(1, &multisample_color_buffer_);
98 if (attributes_.depth || attributes_.stencil) 96 if (attributes_.depth || attributes_.stencil)
99 glDeleteRenderbuffersEXT(1, &multisample_depth_stencil_buffer_); 97 glDeleteRenderbuffersEXT(1, &multisample_depth_stencil_buffer_);
100 glDeleteFramebuffersEXT(1, &multisample_fbo_); 98 glDeleteFramebuffersEXT(1, &multisample_fbo_);
101 } else { 99 } else {
102 if (attributes_.depth || attributes_.stencil) 100 if (attributes_.depth || attributes_.stencil)
103 glDeleteRenderbuffersEXT(1, &depth_stencil_buffer_); 101 glDeleteRenderbuffersEXT(1, &depth_stencil_buffer_);
104 } 102 }
105 glDeleteTextures(1, &texture_); 103 glDeleteTextures(1, &texture_);
106 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
107 if (scanline_) 104 if (scanline_)
108 delete[] scanline_; 105 delete[] scanline_;
109 #endif
110 glDeleteFramebuffersEXT(1, &fbo_); 106 glDeleteFramebuffersEXT(1, &fbo_);
111 107
112 gl_context_->ReleaseCurrent(gl_surface_.get()); 108 gl_context_->ReleaseCurrent(gl_surface_.get());
113 gl_context_->Destroy(); 109 gl_context_->Destroy();
114 gl_surface_->Destroy(); 110 gl_surface_->Destroy();
115 111
116 for (ShaderSourceMap::iterator ii = shader_source_map_.begin(); 112 for (ShaderSourceMap::iterator ii = shader_source_map_.begin();
117 ii != shader_source_map_.end(); ++ii) { 113 ii != shader_source_map_.end(); ++ii) {
118 if (ii->second) 114 if (ii->second)
119 delete ii->second; 115 delete ii->second;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 bool must_restore_fbo = false; 379 bool must_restore_fbo = false;
384 if (gl_surface_->IsOffscreen()) 380 if (gl_surface_->IsOffscreen())
385 must_restore_fbo = AllocateOffscreenFrameBuffer(width, height); 381 must_restore_fbo = AllocateOffscreenFrameBuffer(width, height);
386 382
387 gl_surface_->Resize(gfx::Size(width, height)); 383 gl_surface_->Resize(gfx::Size(width, height));
388 ClearRenderTarget(); 384 ClearRenderTarget();
389 385
390 if (must_restore_fbo) 386 if (must_restore_fbo)
391 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_); 387 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
392 388
393 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
394 if (scanline_) { 389 if (scanline_) {
395 delete[] scanline_; 390 delete[] scanline_;
396 scanline_ = 0; 391 scanline_ = 0;
397 } 392 }
398 scanline_ = new unsigned char[width * 4]; 393 scanline_ = new unsigned char[width * 4];
399 #endif // FLIP_FRAMEBUFFER_VERTICALLY
400 } 394 }
401 395
402 bool WebGraphicsContext3DInProcessImpl::AllocateOffscreenFrameBuffer( 396 bool WebGraphicsContext3DInProcessImpl::AllocateOffscreenFrameBuffer(
403 int width, int height) { 397 int width, int height) {
404 GLenum target = GL_TEXTURE_2D; 398 GLenum target = GL_TEXTURE_2D;
405 399
406 if (!texture_) { 400 if (!texture_) {
407 // Generate the texture object 401 // Generate the texture object
408 texture_ = CreateTextureObject(target); 402 texture_ = CreateTextureObject(target);
409 // Generate the framebuffer object 403 // Generate the framebuffer object
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (isScissorEnabled) 610 if (isScissorEnabled)
617 glEnable(GL_SCISSOR_TEST); 611 glEnable(GL_SCISSOR_TEST);
618 else 612 else
619 glDisable(GL_SCISSOR_TEST); 613 glDisable(GL_SCISSOR_TEST);
620 if (isDitherEnabled) 614 if (isDitherEnabled)
621 glEnable(GL_DITHER); 615 glEnable(GL_DITHER);
622 else 616 else
623 glDisable(GL_DITHER); 617 glDisable(GL_DITHER);
624 } 618 }
625 619
626 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
627 void WebGraphicsContext3DInProcessImpl::FlipVertically( 620 void WebGraphicsContext3DInProcessImpl::FlipVertically(
628 unsigned char* framebuffer, unsigned int width, unsigned int height) { 621 unsigned char* framebuffer, unsigned int width, unsigned int height) {
629 unsigned char* scanline = scanline_; 622 unsigned char* scanline = scanline_;
630 if (!scanline) 623 if (!scanline)
631 return; 624 return;
632 unsigned int row_bytes = width * 4; 625 unsigned int row_bytes = width * 4;
633 unsigned int count = height / 2; 626 unsigned int count = height / 2;
634 for (unsigned int i = 0; i < count; i++) { 627 for (unsigned int i = 0; i < count; i++) {
635 unsigned char* row_a = framebuffer + i * row_bytes; 628 unsigned char* row_a = framebuffer + i * row_bytes;
636 unsigned char* row_b = framebuffer + (height - i - 1) * row_bytes; 629 unsigned char* row_b = framebuffer + (height - i - 1) * row_bytes;
637 // FIXME: this is where the multiplication of the alpha 630 // FIXME: this is where the multiplication of the alpha
638 // channel into the color buffer will need to occur if the 631 // channel into the color buffer will need to occur if the
639 // user specifies the "premultiplyAlpha" flag in the context 632 // user specifies the "premultiplyAlpha" flag in the context
640 // creation attributes. 633 // creation attributes.
641 memcpy(scanline, row_b, row_bytes); 634 memcpy(scanline, row_b, row_bytes);
642 memcpy(row_b, row_a, row_bytes); 635 memcpy(row_b, row_a, row_bytes);
643 memcpy(row_a, scanline, row_bytes); 636 memcpy(row_a, scanline, row_bytes);
644 } 637 }
645 } 638 }
646 #endif
647 639
648 bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer( 640 bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
649 unsigned char* pixels, size_t bufferSize, WebGLId framebuffer, 641 unsigned char* pixels, size_t bufferSize, WebGLId framebuffer,
650 int width, int height) { 642 int width, int height) {
651 if (bufferSize != static_cast<size_t>(4 * width * height)) 643 if (bufferSize != static_cast<size_t>(4 * width * height))
652 return false; 644 return false;
653 645
654 makeContextCurrent(); 646 makeContextCurrent();
655 647
656 // Earlier versions of this code used the GPU to flip the 648 // Earlier versions of this code used the GPU to flip the
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } else { 681 } else {
690 glReadPixels(0, 0, width, height, 682 glReadPixels(0, 0, width, height,
691 GL_BGRA, GL_UNSIGNED_BYTE, pixels); 683 GL_BGRA, GL_UNSIGNED_BYTE, pixels);
692 } 684 }
693 685
694 if (must_restore_pack_alignment) 686 if (must_restore_pack_alignment)
695 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment); 687 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment);
696 688
697 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_); 689 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, bound_fbo_);
698 690
699 #ifdef FLIP_FRAMEBUFFER_VERTICALLY
700 if (pixels) 691 if (pixels)
701 FlipVertically(pixels, width, height); 692 FlipVertically(pixels, width, height);
702 #endif
703 693
704 return true; 694 return true;
705 } 695 }
706 696
707 bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer( 697 bool WebGraphicsContext3DInProcessImpl::readBackFramebuffer(
708 unsigned char* pixels, size_t bufferSize) { 698 unsigned char* pixels, size_t bufferSize) {
709 return readBackFramebuffer(pixels, bufferSize, fbo_, width(), height()); 699 return readBackFramebuffer(pixels, bufferSize, fbo_, width(), height());
710 } 700 }
711 701
712 void WebGraphicsContext3DInProcessImpl::synthesizeGLError(WGC3Denum error) { 702 void WebGraphicsContext3DInProcessImpl::synthesizeGLError(WGC3Denum error) {
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 if (length > 1) { 1814 if (length > 1) {
1825 entry->translated_source.reset(new char[length]); 1815 entry->translated_source.reset(new char[length]);
1826 ShGetObjectCode(compiler, entry->translated_source.get()); 1816 ShGetObjectCode(compiler, entry->translated_source.get());
1827 } 1817 }
1828 entry->is_valid = true; 1818 entry->is_valid = true;
1829 return true; 1819 return true;
1830 } 1820 }
1831 1821
1832 } // namespace gpu 1822 } // namespace gpu
1833 } // namespace webkit 1823 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698