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

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

Issue 1311413003: Remove duplicate formats and types validation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 IntRect destRect(0, 0, size.width(), size.height()); 4115 IntRect destRect(0, 0, size.width(), size.height());
4116 SkPaint paint; 4116 SkPaint paint;
4117 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect); 4117 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect);
4118 return buf->newImageSnapshot(); 4118 return buf->newImageSnapshot();
4119 } 4119 }
4120 4120
4121 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 4121 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
4122 GLsizei width, GLsizei height, GLint border, 4122 GLsizei width, GLsizei height, GLint border,
4123 GLenum format, GLenum type, DOMArrayBufferView* pixels) 4123 GLenum format, GLenum type, DOMArrayBufferView* pixels)
4124 { 4124 {
4125 if (isContextLost() || !validateTexFuncData("texImage2D", level, width, heig ht, internalformat, format, type, pixels, NullAllowed) 4125 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0)
4126 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferVie w, target, level, internalformat, width, height, border, format, type, 0, 0)) 4126 || !validateTexFuncData("texImage2D", level, width, height, internalform at, format, type, pixels, NullAllowed))
4127 return; 4127 return;
4128 void* data = pixels ? pixels->baseAddress() : 0; 4128 void* data = pixels ? pixels->baseAddress() : 0;
4129 Vector<uint8_t> tempData; 4129 Vector<uint8_t> tempData;
4130 bool changeUnpackAlignment = false; 4130 bool changeUnpackAlignment = false;
4131 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { 4131 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
4132 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) 4132 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData))
4133 return; 4133 return;
4134 data = tempData.data(); 4134 data = tempData.data();
4135 changeUnpackAlignment = true; 4135 changeUnpackAlignment = true;
4136 } 4136 }
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
4441 4441
4442 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 4442 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
4443 GLsizei width, GLsizei height, 4443 GLsizei width, GLsizei height,
4444 GLenum format, GLenum type, DOMArrayBufferView* pixels) 4444 GLenum format, GLenum type, DOMArrayBufferView* pixels)
4445 { 4445 {
4446 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true ); 4446 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true );
4447 if (!texture) 4447 if (!texture)
4448 return; 4448 return;
4449 4449
4450 GLenum internalformat = texture->getInternalFormat(target, level); 4450 GLenum internalformat = texture->getInternalFormat(target, level);
4451 if (isContextLost() || !validateTexFuncData("texSubImage2D", level, width, h eight, internalformat, format, type, pixels, NullNotAllowed) 4451 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yo ffset)
4452 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferVie w, target, level, 0, width, height, 0, format, type, xoffset, yoffset)) 4452 || !validateTexFuncData("texSubImage2D", level, width, height, internalf ormat, format, type, pixels, NullNotAllowed))
4453 return; 4453 return;
4454 void* data = pixels->baseAddress(); 4454 void* data = pixels->baseAddress();
4455 Vector<uint8_t> tempData; 4455 Vector<uint8_t> tempData;
4456 bool changeUnpackAlignment = false; 4456 bool changeUnpackAlignment = false;
4457 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { 4457 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) {
4458 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e, 4458 if (!WebGLImageConversion::extractTextureData(width, height, format, typ e,
4459 m_unpackAlignment, 4459 m_unpackAlignment,
4460 m_unpackFlipY, m_unpackPremultiplyAlp ha, 4460 m_unpackFlipY, m_unpackPremultiplyAlp ha,
4461 data, 4461 data,
4462 tempData)) 4462 tempData))
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
5524 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL int level, GLsizei width, GLsizei height, GLenum internalformat, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition) 5524 bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL int level, GLsizei width, GLsizei height, GLenum internalformat, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition)
5525 { 5525 {
5526 // All calling functions check isContextLost, so a duplicate check is not ne eded here. 5526 // All calling functions check isContextLost, so a duplicate check is not ne eded here.
5527 if (!pixels) { 5527 if (!pixels) {
5528 if (disposition == NullAllowed) 5528 if (disposition == NullAllowed)
5529 return true; 5529 return true;
5530 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels"); 5530 synthesizeGLError(GL_INVALID_VALUE, functionName, "no pixels");
5531 return false; 5531 return false;
5532 } 5532 }
5533 5533
5534 if (!validateTexFuncFormatAndType(functionName, internalformat, format, type , level))
5535 return false;
5536 if (!validateSettableTexFormat(functionName, format)) 5534 if (!validateSettableTexFormat(functionName, format))
5537 return false; 5535 return false;
5538 5536
5539 switch (type) { 5537 switch (type) {
5540 case GL_BYTE: 5538 case GL_BYTE:
5541 if (pixels->type() != DOMArrayBufferView::TypeInt8) { 5539 if (pixels->type() != DOMArrayBufferView::TypeInt8) {
5542 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type BYTE but ArrayBufferView not Int8Array"); 5540 synthesizeGLError(GL_INVALID_OPERATION, functionName, "type BYTE but ArrayBufferView not Int8Array");
5543 return false; 5541 return false;
5544 } 5542 }
5545 break; 5543 break;
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6683 6681
6684 return totalBytesPerPixel; 6682 return totalBytesPerPixel;
6685 } 6683 }
6686 6684
6687 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6685 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6688 { 6686 {
6689 return m_drawingBuffer.get(); 6687 return m_drawingBuffer.get();
6690 } 6688 }
6691 6689
6692 } // namespace blink 6690 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698