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

Side by Side Diff: Source/platform/graphics/GraphicsContext3D.cpp

Issue 127163003: Completely removed the Extensions3D class (Take 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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 /* 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 459
460 DELEGATE_TO_WEBCONTEXT_1(deleteBuffer, Platform3DObject) 460 DELEGATE_TO_WEBCONTEXT_1(deleteBuffer, Platform3DObject)
461 DELEGATE_TO_WEBCONTEXT_1(deleteFramebuffer, Platform3DObject) 461 DELEGATE_TO_WEBCONTEXT_1(deleteFramebuffer, Platform3DObject)
462 DELEGATE_TO_WEBCONTEXT_1(deleteProgram, Platform3DObject) 462 DELEGATE_TO_WEBCONTEXT_1(deleteProgram, Platform3DObject)
463 DELEGATE_TO_WEBCONTEXT_1(deleteRenderbuffer, Platform3DObject) 463 DELEGATE_TO_WEBCONTEXT_1(deleteRenderbuffer, Platform3DObject)
464 DELEGATE_TO_WEBCONTEXT_1(deleteShader, Platform3DObject) 464 DELEGATE_TO_WEBCONTEXT_1(deleteShader, Platform3DObject)
465 DELEGATE_TO_WEBCONTEXT_1(deleteTexture, Platform3DObject) 465 DELEGATE_TO_WEBCONTEXT_1(deleteTexture, Platform3DObject)
466 466
467 DELEGATE_TO_WEBCONTEXT_1(synthesizeGLError, GLenum) 467 DELEGATE_TO_WEBCONTEXT_1(synthesizeGLError, GLenum)
468 468
469 Extensions3D* GraphicsContext3D::extensions()
470 {
471 if (!m_extensions)
472 m_extensions = adoptPtr(new Extensions3D(this));
473 return m_extensions.get();
474 }
475
476 bool GraphicsContext3D::texImage2DResourceSafe(GLenum target, GLint level, GLenu m internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GL enum type, GLint unpackAlignment) 469 bool GraphicsContext3D::texImage2DResourceSafe(GLenum target, GLint level, GLenu m internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GL enum type, GLint unpackAlignment)
477 { 470 {
478 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); 471 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8);
479 texImage2D(target, level, internalformat, width, height, border, format, typ e, 0); 472 texImage2D(target, level, internalformat, width, height, border, format, typ e, 0);
480 return true; 473 return true;
481 } 474 }
482 475
483 bool GraphicsContext3D::computeFormatAndTypeParameters(GLenum format, GLenum typ e, unsigned* componentsPerPixel, unsigned* bytesPerComponent) 476 bool GraphicsContext3D::computeFormatAndTypeParameters(GLenum format, GLenum typ e, unsigned* componentsPerPixel, unsigned* bytesPerComponent)
484 { 477 {
485 switch (format) { 478 switch (format) {
486 case GL_ALPHA: 479 case GL_ALPHA:
487 case GL_LUMINANCE: 480 case GL_LUMINANCE:
488 case GL_DEPTH_COMPONENT: 481 case GL_DEPTH_COMPONENT:
489 case GL_DEPTH_STENCIL_OES: 482 case GL_DEPTH_STENCIL_OES:
490 *componentsPerPixel = 1; 483 *componentsPerPixel = 1;
491 break; 484 break;
492 case GL_LUMINANCE_ALPHA: 485 case GL_LUMINANCE_ALPHA:
493 *componentsPerPixel = 2; 486 *componentsPerPixel = 2;
494 break; 487 break;
495 case GL_RGB: 488 case GL_RGB:
496 *componentsPerPixel = 3; 489 *componentsPerPixel = 3;
497 break; 490 break;
498 case GL_RGBA: 491 case GL_RGBA:
499 case Extensions3D::BGRA_EXT: // GL_EXT_texture_format_BGRA8888 492 case GL_BGRA_EXT: // GL_EXT_texture_format_BGRA8888
500 *componentsPerPixel = 4; 493 *componentsPerPixel = 4;
501 break; 494 break;
502 default: 495 default:
503 return false; 496 return false;
504 } 497 }
505 switch (type) { 498 switch (type) {
506 case GL_UNSIGNED_BYTE: 499 case GL_UNSIGNED_BYTE:
507 *bytesPerComponent = sizeof(GLubyte); 500 *bytesPerComponent = sizeof(GLubyte);
508 break; 501 break;
509 case GL_UNSIGNED_SHORT: 502 case GL_UNSIGNED_SHORT:
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 return m_enabledExtensions.contains(mappedName); 786 return m_enabledExtensions.contains(mappedName);
794 } 787 }
795 788
796 bool GraphicsContext3D::isExtensionEnabled(const String& name) 789 bool GraphicsContext3D::isExtensionEnabled(const String& name)
797 { 790 {
798 initializeExtensions(); 791 initializeExtensions();
799 String mappedName = mapExtensionName(name); 792 String mappedName = mapExtensionName(name);
800 return m_enabledExtensions.contains(mappedName); 793 return m_enabledExtensions.contains(mappedName);
801 } 794 }
802 795
796 bool GraphicsContext3D::canUseCopyTextureCHROMIUM(GLenum destFormat, GLenum dest Type, GLint level)
797 {
798 // FIXME: restriction of (RGB || RGBA)/UNSIGNED_BYTE/(Level 0) should be lif ted when
799 // WebGraphicsContext3D::copyTextureCHROMIUM(...) are fully functional.
800 if ((destFormat == GL_RGB || destFormat == GL_RGBA)
801 && destType == GL_UNSIGNED_BYTE
802 && !level)
803 return true;
804 return false;
805 }
806
803 void GraphicsContext3D::flipVertically(uint8_t* framebuffer, int width, int heig ht) 807 void GraphicsContext3D::flipVertically(uint8_t* framebuffer, int width, int heig ht)
804 { 808 {
805 m_scanline.resize(width * 4); 809 m_scanline.resize(width * 4);
806 uint8* scanline = &m_scanline[0]; 810 uint8* scanline = &m_scanline[0];
807 unsigned rowBytes = width * 4; 811 unsigned rowBytes = width * 4;
808 unsigned count = height / 2; 812 unsigned count = height / 2;
809 for (unsigned i = 0; i < count; i++) { 813 for (unsigned i = 0; i < count; i++) {
810 uint8* rowA = framebuffer + i * rowBytes; 814 uint8* rowA = framebuffer + i * rowBytes;
811 uint8* rowB = framebuffer + (height - i - 1) * rowBytes; 815 uint8* rowB = framebuffer + (height - i - 1) * rowBytes;
812 memcpy(scanline, rowB, rowBytes); 816 memcpy(scanline, rowB, rowBytes);
813 memcpy(rowB, rowA, rowBytes); 817 memcpy(rowB, rowA, rowBytes);
814 memcpy(rowA, scanline, rowBytes); 818 memcpy(rowA, scanline, rowBytes);
815 } 819 }
816 } 820 }
817 821
818 } // namespace WebCore 822 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext3D.h ('k') | Source/platform/graphics/GraphicsTypes3D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698