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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1938493002: [Reland] Fix ReadPixels from float fbo buffer in ES2/WebGL1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after
3541 return true; 3541 return true;
3542 case GL_UNSIGNED_SHORT_5_6_5: 3542 case GL_UNSIGNED_SHORT_5_6_5:
3543 case GL_UNSIGNED_SHORT_4_4_4_4: 3543 case GL_UNSIGNED_SHORT_4_4_4_4:
3544 case GL_UNSIGNED_SHORT_5_5_5_1: 3544 case GL_UNSIGNED_SHORT_5_5_5_1:
3545 if (buffer && buffer->type() != DOMArrayBufferView::TypeUint16) { 3545 if (buffer && buffer->type() != DOMArrayBufferView::TypeUint16) {
3546 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "type UNSIGNED _SHORT but ArrayBufferView not Uint16Array"); 3546 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "type UNSIGNED _SHORT but ArrayBufferView not Uint16Array");
3547 return false; 3547 return false;
3548 } 3548 }
3549 return true; 3549 return true;
3550 case GL_FLOAT: 3550 case GL_FLOAT:
3551 if (extensionEnabled(OESTextureFloatName)) { 3551 if (extensionEnabled(OESTextureFloatName) || extensionEnabled(OESTexture HalfFloatName)) {
3552 if (buffer && buffer->type() != DOMArrayBufferView::TypeFloat32) { 3552 if (buffer && buffer->type() != DOMArrayBufferView::TypeFloat32) {
3553 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "type FLOA T but ArrayBufferView not Float32Array"); 3553 synthesizeGLError(GL_INVALID_OPERATION, "readPixels", "type FLOA T but ArrayBufferView not Float32Array");
3554 return false; 3554 return false;
3555 } 3555 }
3556 return true; 3556 return true;
3557 } 3557 }
3558 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type"); 3558 synthesizeGLError(GL_INVALID_ENUM, "readPixels", "invalid type");
3559 return false; 3559 return false;
3560 case GL_HALF_FLOAT_OES: 3560 case GL_HALF_FLOAT_OES:
3561 if (extensionEnabled(OESTextureHalfFloatName)) { 3561 if (extensionEnabled(OESTextureHalfFloatName)) {
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
5121 { 5121 {
5122 GLfloat value = 0; 5122 GLfloat value = 0;
5123 if (!isContextLost()) 5123 if (!isContextLost())
5124 contextGL()->GetFloatv(pname, &value); 5124 contextGL()->GetFloatv(pname, &value);
5125 return WebGLAny(scriptState, value); 5125 return WebGLAny(scriptState, value);
5126 } 5126 }
5127 5127
5128 ScriptValue WebGLRenderingContextBase::getIntParameter(ScriptState* scriptState, GLenum pname) 5128 ScriptValue WebGLRenderingContextBase::getIntParameter(ScriptState* scriptState, GLenum pname)
5129 { 5129 {
5130 GLint value = 0; 5130 GLint value = 0;
5131 if (!isContextLost()) 5131 if (!isContextLost()) {
5132 contextGL()->GetIntegerv(pname, &value); 5132 contextGL()->GetIntegerv(pname, &value);
5133 switch (pname) {
5134 case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
5135 case GL_IMPLEMENTATION_COLOR_READ_TYPE:
5136 if (value == 0) {
5137 // This indicates read framebuffer is incomplete and an
5138 // INVALID_OPERATION has been generated.
5139 return ScriptValue::createNull(scriptState);
5140 }
5141 break;
5142 default:
5143 break;
5144 }
5145 }
5133 return WebGLAny(scriptState, value); 5146 return WebGLAny(scriptState, value);
5134 } 5147 }
5135 5148
5136 ScriptValue WebGLRenderingContextBase::getInt64Parameter(ScriptState* scriptStat e, GLenum pname) 5149 ScriptValue WebGLRenderingContextBase::getInt64Parameter(ScriptState* scriptStat e, GLenum pname)
5137 { 5150 {
5138 GLint64 value = 0; 5151 GLint64 value = 0;
5139 if (!isContextLost()) 5152 if (!isContextLost())
5140 contextGL()->GetInteger64v(pname, &value); 5153 contextGL()->GetInteger64v(pname, &value);
5141 return WebGLAny(scriptState, value); 5154 return WebGLAny(scriptState, value);
5142 } 5155 }
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
6258 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6271 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6259 } 6272 }
6260 6273
6261 void WebGLRenderingContextBase::restoreUnpackParameters() 6274 void WebGLRenderingContextBase::restoreUnpackParameters()
6262 { 6275 {
6263 if (m_unpackAlignment != 1) 6276 if (m_unpackAlignment != 1)
6264 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6277 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6265 } 6278 }
6266 6279
6267 } // namespace blink 6280 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698