| OLD | NEW |
| 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 4043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 return true; | 4054 return true; |
| 4055 } | 4055 } |
| 4056 | 4056 |
| 4057 void WebGLRenderingContextBase::readPixels(GLint x, | 4057 void WebGLRenderingContextBase::readPixels(GLint x, |
| 4058 GLint y, | 4058 GLint y, |
| 4059 GLsizei width, | 4059 GLsizei width, |
| 4060 GLsizei height, | 4060 GLsizei height, |
| 4061 GLenum format, | 4061 GLenum format, |
| 4062 GLenum type, | 4062 GLenum type, |
| 4063 DOMArrayBufferView* pixels) { | 4063 DOMArrayBufferView* pixels) { |
| 4064 readPixelsHelper(x, y, width, height, format, type, pixels, 0); |
| 4065 } |
| 4066 |
| 4067 void WebGLRenderingContextBase::readPixelsHelper(GLint x, |
| 4068 GLint y, |
| 4069 GLsizei width, |
| 4070 GLsizei height, |
| 4071 GLenum format, |
| 4072 GLenum type, |
| 4073 DOMArrayBufferView* pixels, |
| 4074 GLuint offset) { |
| 4064 if (isContextLost()) | 4075 if (isContextLost()) |
| 4065 return; | 4076 return; |
| 4066 // Due to WebGL's same-origin restrictions, it is not possible to | 4077 // Due to WebGL's same-origin restrictions, it is not possible to |
| 4067 // taint the origin using the WebGL API. | 4078 // taint the origin using the WebGL API. |
| 4068 ASSERT(canvas()->originClean()); | 4079 ASSERT(canvas()->originClean()); |
| 4069 // Validate input parameters. | 4080 // Validate input parameters. |
| 4070 if (!pixels) { | 4081 if (!pixels) { |
| 4071 synthesizeGLError(GL_INVALID_VALUE, "readPixels", | 4082 synthesizeGLError(GL_INVALID_VALUE, "readPixels", |
| 4072 "no destination ArrayBufferView"); | 4083 "no destination ArrayBufferView"); |
| 4073 return; | 4084 return; |
| 4074 } | 4085 } |
| 4086 CheckedNumeric<GLuint> offsetInBytes = offset; |
| 4087 offsetInBytes *= pixels->typeSize(); |
| 4088 if (!offsetInBytes.IsValid() || |
| 4089 offsetInBytes.ValueOrDie() > pixels->byteLength()) { |
| 4090 synthesizeGLError(GL_INVALID_VALUE, "readPixels", |
| 4091 "destination offset out of range"); |
| 4092 return; |
| 4093 } |
| 4075 const char* reason = "framebuffer incomplete"; | 4094 const char* reason = "framebuffer incomplete"; |
| 4076 WebGLFramebuffer* framebuffer = getReadFramebufferBinding(); | 4095 WebGLFramebuffer* framebuffer = getReadFramebufferBinding(); |
| 4077 if (framebuffer && | 4096 if (framebuffer && |
| 4078 framebuffer->checkDepthStencilStatus(&reason) != | 4097 framebuffer->checkDepthStencilStatus(&reason) != |
| 4079 GL_FRAMEBUFFER_COMPLETE) { | 4098 GL_FRAMEBUFFER_COMPLETE) { |
| 4080 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason); | 4099 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason); |
| 4081 return; | 4100 return; |
| 4082 } | 4101 } |
| 4083 if (!validateReadPixelsFuncParameters( | 4102 if (!validateReadPixelsFuncParameters( |
| 4084 width, height, format, type, pixels, | 4103 width, height, format, type, pixels, |
| 4085 static_cast<long long>(pixels->byteLength()))) | 4104 static_cast<long long>(pixels->byteLength() - |
| 4105 offsetInBytes.ValueOrDie()))) { |
| 4086 return; | 4106 return; |
| 4087 | 4107 } |
| 4088 clearIfComposited(); | 4108 clearIfComposited(); |
| 4089 void* data = pixels->baseAddress(); | 4109 uint8_t* data = |
| 4090 | 4110 static_cast<uint8_t*>(pixels->baseAddress()) + offsetInBytes.ValueOrDie(); |
| 4091 { | 4111 { |
| 4092 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); | 4112 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); |
| 4093 contextGL()->ReadPixels(x, y, width, height, format, type, data); | 4113 contextGL()->ReadPixels(x, y, width, height, format, type, data); |
| 4094 } | 4114 } |
| 4095 } | 4115 } |
| 4096 | 4116 |
| 4097 void WebGLRenderingContextBase::renderbufferStorageImpl( | 4117 void WebGLRenderingContextBase::renderbufferStorageImpl( |
| 4098 GLenum target, | 4118 GLenum target, |
| 4099 GLsizei samples, | 4119 GLsizei samples, |
| 4100 GLenum internalformat, | 4120 GLenum internalformat, |
| (...skipping 3508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7609 | 7629 |
| 7610 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7630 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7611 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7631 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7612 if (canvas()) | 7632 if (canvas()) |
| 7613 result.setHTMLCanvasElement(canvas()); | 7633 result.setHTMLCanvasElement(canvas()); |
| 7614 else | 7634 else |
| 7615 result.setOffscreenCanvas(getOffscreenCanvas()); | 7635 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7616 } | 7636 } |
| 7617 | 7637 |
| 7618 } // namespace blink | 7638 } // namespace blink |
| OLD | NEW |