Chromium Code Reviews| 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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 public: | 494 public: |
| 495 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context) | 495 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context) |
| 496 : m_context(context) {} | 496 : m_context(context) {} |
| 497 | 497 |
| 498 ~ScopedFramebufferRestorer() { m_context->restoreCurrentFramebuffer(); } | 498 ~ScopedFramebufferRestorer() { m_context->restoreCurrentFramebuffer(); } |
| 499 | 499 |
| 500 private: | 500 private: |
| 501 Member<WebGLRenderingContextBase> m_context; | 501 Member<WebGLRenderingContextBase> m_context; |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 class ScopedUnpackParametersResetRestore { | |
| 505 STACK_ALLOCATED(); | |
| 506 | |
| 507 public: | |
| 508 explicit ScopedUnpackParametersResetRestore( | |
| 509 WebGLRenderingContextBase* context, | |
| 510 bool enabled = true) | |
|
pdr.
2016/11/22 19:16:01
This restore class is a nice way of cleaning up th
Ken Russell (switch to Gerrit)
2016/11/22 22:47:44
+1, this is nice.
| |
| 511 : m_context(context), m_enabled(enabled) { | |
| 512 if (enabled) | |
| 513 m_context->resetUnpackParameters(); | |
| 514 } | |
| 515 | |
| 516 ~ScopedUnpackParametersResetRestore() { | |
| 517 if (m_enabled) | |
| 518 m_context->restoreUnpackParameters(); | |
| 519 } | |
| 520 | |
| 521 private: | |
| 522 Member<WebGLRenderingContextBase> m_context; | |
| 523 bool m_enabled; | |
| 524 }; | |
| 525 | |
| 504 static void formatWebGLStatusString(const StringView& glInfo, | 526 static void formatWebGLStatusString(const StringView& glInfo, |
| 505 const StringView& infoString, | 527 const StringView& infoString, |
| 506 StringBuilder& builder) { | 528 StringBuilder& builder) { |
| 507 if (infoString.isEmpty()) | 529 if (infoString.isEmpty()) |
| 508 return; | 530 return; |
| 509 builder.append(", "); | 531 builder.append(", "); |
| 510 builder.append(glInfo); | 532 builder.append(glInfo); |
| 511 builder.append(" = "); | 533 builder.append(" = "); |
| 512 builder.append(infoString); | 534 builder.append(infoString); |
| 513 } | 535 } |
| (...skipping 3896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4410 image, imagePixelData, format, type, flipY, alphaOp, | 4432 image, imagePixelData, format, type, flipY, alphaOp, |
| 4411 sourceDataFormat, imageExtractor.imageWidth(), | 4433 sourceDataFormat, imageExtractor.imageWidth(), |
| 4412 imageExtractor.imageHeight(), adjustedSourceImageRect, depth, | 4434 imageExtractor.imageHeight(), adjustedSourceImageRect, depth, |
| 4413 imageExtractor.imageSourceUnpackAlignment(), unpackImageHeight, | 4435 imageExtractor.imageSourceUnpackAlignment(), unpackImageHeight, |
| 4414 data)) { | 4436 data)) { |
| 4415 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); | 4437 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); |
| 4416 return; | 4438 return; |
| 4417 } | 4439 } |
| 4418 } | 4440 } |
| 4419 | 4441 |
| 4420 resetUnpackParameters(); | 4442 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 4421 if (functionID == TexImage2D) { | 4443 if (functionID == TexImage2D) { |
| 4422 texImage2DBase(target, level, internalformat, | 4444 texImage2DBase(target, level, internalformat, |
| 4423 adjustedSourceImageRect.width(), | 4445 adjustedSourceImageRect.width(), |
| 4424 adjustedSourceImageRect.height(), 0, format, type, | 4446 adjustedSourceImageRect.height(), 0, format, type, |
| 4425 needConversion ? data.data() : imagePixelData); | 4447 needConversion ? data.data() : imagePixelData); |
| 4426 } else if (functionID == TexSubImage2D) { | 4448 } else if (functionID == TexSubImage2D) { |
| 4427 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, | 4449 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, |
| 4428 adjustedSourceImageRect.width(), | 4450 adjustedSourceImageRect.width(), |
| 4429 adjustedSourceImageRect.height(), format, type, | 4451 adjustedSourceImageRect.height(), format, type, |
| 4430 needConversion ? data.data() : imagePixelData); | 4452 needConversion ? data.data() : imagePixelData); |
| 4431 } else { | 4453 } else { |
| 4432 // 3D functions. | 4454 // 3D functions. |
| 4433 if (functionID == TexImage3D) { | 4455 if (functionID == TexImage3D) { |
| 4434 contextGL()->TexImage3D( | 4456 contextGL()->TexImage3D( |
| 4435 target, level, internalformat, adjustedSourceImageRect.width(), | 4457 target, level, internalformat, adjustedSourceImageRect.width(), |
| 4436 adjustedSourceImageRect.height(), depth, 0, format, type, | 4458 adjustedSourceImageRect.height(), depth, 0, format, type, |
| 4437 needConversion ? data.data() : imagePixelData); | 4459 needConversion ? data.data() : imagePixelData); |
| 4438 } else { | 4460 } else { |
| 4439 DCHECK_EQ(functionID, TexSubImage3D); | 4461 DCHECK_EQ(functionID, TexSubImage3D); |
| 4440 contextGL()->TexSubImage3D( | 4462 contextGL()->TexSubImage3D( |
| 4441 target, level, xoffset, yoffset, zoffset, | 4463 target, level, xoffset, yoffset, zoffset, |
| 4442 adjustedSourceImageRect.width(), adjustedSourceImageRect.height(), | 4464 adjustedSourceImageRect.width(), adjustedSourceImageRect.height(), |
| 4443 depth, format, type, needConversion ? data.data() : imagePixelData); | 4465 depth, format, type, needConversion ? data.data() : imagePixelData); |
| 4444 } | 4466 } |
| 4445 } | 4467 } |
| 4446 restoreUnpackParameters(); | |
| 4447 } | 4468 } |
| 4448 | 4469 |
| 4449 bool WebGLRenderingContextBase::validateTexFunc( | 4470 bool WebGLRenderingContextBase::validateTexFunc( |
| 4450 const char* functionName, | 4471 const char* functionName, |
| 4451 TexImageFunctionType functionType, | 4472 TexImageFunctionType functionType, |
| 4452 TexFuncValidationSourceType sourceType, | 4473 TexFuncValidationSourceType sourceType, |
| 4453 GLenum target, | 4474 GLenum target, |
| 4454 GLint level, | 4475 GLint level, |
| 4455 GLenum internalformat, | 4476 GLenum internalformat, |
| 4456 GLsizei width, | 4477 GLsizei width, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4643 convertTexInternalFormat(internalformat, type), | 4664 convertTexInternalFormat(internalformat, type), |
| 4644 width, height, depth, border, format, type, data); | 4665 width, height, depth, border, format, type, data); |
| 4645 return; | 4666 return; |
| 4646 } | 4667 } |
| 4647 if (functionID == TexSubImage3D) { | 4668 if (functionID == TexSubImage3D) { |
| 4648 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, | 4669 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, |
| 4649 height, depth, format, type, data); | 4670 height, depth, format, type, data); |
| 4650 return; | 4671 return; |
| 4651 } | 4672 } |
| 4652 | 4673 |
| 4653 if (changeUnpackAlignment) | 4674 ScopedUnpackParametersResetRestore temporaryResetUnpack( |
| 4654 resetUnpackParameters(); | 4675 this, changeUnpackAlignment); |
| 4655 if (functionID == TexImage2D) | 4676 if (functionID == TexImage2D) |
| 4656 texImage2DBase(target, level, internalformat, width, height, border, format, | 4677 texImage2DBase(target, level, internalformat, width, height, border, format, |
| 4657 type, data); | 4678 type, data); |
| 4658 else if (functionID == TexSubImage2D) | 4679 else if (functionID == TexSubImage2D) |
| 4659 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, | 4680 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, |
| 4660 format, type, data); | 4681 format, type, data); |
| 4661 if (changeUnpackAlignment) | |
| 4662 restoreUnpackParameters(); | |
| 4663 } | 4682 } |
| 4664 | 4683 |
| 4665 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4684 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 4666 GLint level, | 4685 GLint level, |
| 4667 GLint internalformat, | 4686 GLint internalformat, |
| 4668 GLsizei width, | 4687 GLsizei width, |
| 4669 GLsizei height, | 4688 GLsizei height, |
| 4670 GLint border, | 4689 GLint border, |
| 4671 GLenum format, | 4690 GLenum format, |
| 4672 GLenum type, | 4691 GLenum type, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4740 } | 4759 } |
| 4741 if (!WebGLImageConversion::extractImageData( | 4760 if (!WebGLImageConversion::extractImageData( |
| 4742 pixels->data()->data(), | 4761 pixels->data()->data(), |
| 4743 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), | 4762 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), |
| 4744 adjustedSourceImageRect, depth, unpackImageHeight, format, type, | 4763 adjustedSourceImageRect, depth, unpackImageHeight, format, type, |
| 4745 m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { | 4764 m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
| 4746 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 4765 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
| 4747 return; | 4766 return; |
| 4748 } | 4767 } |
| 4749 } | 4768 } |
| 4750 resetUnpackParameters(); | 4769 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 4751 const uint8_t* bytes = needConversion ? data.data() : pixels->data()->data(); | 4770 const uint8_t* bytes = needConversion ? data.data() : pixels->data()->data(); |
| 4752 if (functionID == TexImage2D) { | 4771 if (functionID == TexImage2D) { |
| 4753 DCHECK_EQ(unpackImageHeight, 0); | 4772 DCHECK_EQ(unpackImageHeight, 0); |
| 4754 texImage2DBase( | 4773 texImage2DBase( |
| 4755 target, level, internalformat, adjustedSourceImageRect.width(), | 4774 target, level, internalformat, adjustedSourceImageRect.width(), |
| 4756 adjustedSourceImageRect.height(), border, format, type, bytes); | 4775 adjustedSourceImageRect.height(), border, format, type, bytes); |
| 4757 } else if (functionID == TexSubImage2D) { | 4776 } else if (functionID == TexSubImage2D) { |
| 4758 DCHECK_EQ(unpackImageHeight, 0); | 4777 DCHECK_EQ(unpackImageHeight, 0); |
| 4759 contextGL()->TexSubImage2D( | 4778 contextGL()->TexSubImage2D( |
| 4760 target, level, xoffset, yoffset, adjustedSourceImageRect.width(), | 4779 target, level, xoffset, yoffset, adjustedSourceImageRect.width(), |
| 4761 adjustedSourceImageRect.height(), format, type, bytes); | 4780 adjustedSourceImageRect.height(), format, type, bytes); |
| 4762 } else { | 4781 } else { |
| 4763 GLint uploadHeight = adjustedSourceImageRect.height(); | 4782 GLint uploadHeight = adjustedSourceImageRect.height(); |
| 4764 if (unpackImageHeight) { | 4783 if (unpackImageHeight) { |
| 4765 // GL_UNPACK_IMAGE_HEIGHT overrides the passed-in height. | 4784 // GL_UNPACK_IMAGE_HEIGHT overrides the passed-in height. |
| 4766 uploadHeight = unpackImageHeight; | 4785 uploadHeight = unpackImageHeight; |
| 4767 } | 4786 } |
| 4768 if (functionID == TexImage3D) { | 4787 if (functionID == TexImage3D) { |
| 4769 contextGL()->TexImage3D(target, level, internalformat, | 4788 contextGL()->TexImage3D(target, level, internalformat, |
| 4770 adjustedSourceImageRect.width(), uploadHeight, | 4789 adjustedSourceImageRect.width(), uploadHeight, |
| 4771 depth, border, format, type, bytes); | 4790 depth, border, format, type, bytes); |
| 4772 } else { | 4791 } else { |
| 4773 DCHECK_EQ(functionID, TexSubImage3D); | 4792 DCHECK_EQ(functionID, TexSubImage3D); |
| 4774 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 4793 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
| 4775 adjustedSourceImageRect.width(), uploadHeight, | 4794 adjustedSourceImageRect.width(), uploadHeight, |
| 4776 depth, format, type, bytes); | 4795 depth, format, type, bytes); |
| 4777 } | 4796 } |
| 4778 } | 4797 } |
| 4779 restoreUnpackParameters(); | |
| 4780 } | 4798 } |
| 4781 | 4799 |
| 4782 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4800 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 4783 GLint level, | 4801 GLint level, |
| 4784 GLint internalformat, | 4802 GLint internalformat, |
| 4785 GLenum format, | 4803 GLenum format, |
| 4786 GLenum type, | 4804 GLenum type, |
| 4787 ImageData* pixels) { | 4805 ImageData* pixels) { |
| 4788 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, | 4806 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, |
| 4789 type, 1, 0, 0, 0, pixels, getImageDataSize(pixels), | 4807 type, 1, 0, 0, 0, pixels, getImageDataSize(pixels), |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5139 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, | 5157 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, |
| 5140 level, internalformat, video->videoWidth(), | 5158 level, internalformat, video->videoWidth(), |
| 5141 video->videoHeight(), 1, 0, format, type, xoffset, | 5159 video->videoHeight(), 1, 0, format, type, xoffset, |
| 5142 yoffset, zoffset)) | 5160 yoffset, zoffset)) |
| 5143 return; | 5161 return; |
| 5144 | 5162 |
| 5145 bool sourceImageRectIsDefault = | 5163 bool sourceImageRectIsDefault = |
| 5146 sourceImageRect == sentinelEmptyRect() || | 5164 sourceImageRect == sentinelEmptyRect() || |
| 5147 sourceImageRect == | 5165 sourceImageRect == |
| 5148 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5166 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
| 5149 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1) { | 5167 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
| 5168 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM( | |
| 5169 target, internalformat, type, level)) { | |
|
Ken Russell (switch to Gerrit)
2016/11/22 22:47:44
This change to the if-test will make the semi-acce
aleksandar.stojiljkovic
2016/11/22 23:21:06
The change here is orthogonal in respect to the re
aleksandar.stojiljkovic
2016/11/29 11:59:53
Done. This landed in crrev.com/2527343002.
| |
| 5150 DCHECK_EQ(xoffset, 0); | 5170 DCHECK_EQ(xoffset, 0); |
| 5151 DCHECK_EQ(yoffset, 0); | 5171 DCHECK_EQ(yoffset, 0); |
| 5152 DCHECK_EQ(zoffset, 0); | 5172 DCHECK_EQ(zoffset, 0); |
| 5153 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5173 // Go through the fast path doing a GPU-GPU textures copy without a readback |
| 5154 // to system memory if possible. Otherwise, it will fall back to the normal | 5174 // to system memory if possible. Otherwise, it will fall back to the normal |
| 5155 // SW path. | 5175 // SW path. |
| 5156 if (GL_TEXTURE_2D == target) { | 5176 if (video->copyVideoTextureToPlatformTexture( |
| 5157 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, | 5177 contextGL(), texture->object(), internalformat, type, |
| 5158 type, level) && | 5178 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 5159 video->copyVideoTextureToPlatformTexture( | 5179 return; |
| 5160 contextGL(), texture->object(), internalformat, type, | 5180 } |
| 5161 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | |
| 5162 return; | |
| 5163 } | |
| 5164 | 5181 |
| 5165 // Try using an accelerated image buffer, this allows YUV conversion to be | 5182 // Try using an accelerated image buffer, this allows YUV conversion to be |
| 5166 // done on the GPU. | 5183 // done on the GPU. |
| 5167 std::unique_ptr<ImageBufferSurface> surface = | 5184 std::unique_ptr<ImageBufferSurface> surface = |
| 5168 wrapUnique(new AcceleratedImageBufferSurface( | 5185 wrapUnique(new AcceleratedImageBufferSurface( |
| 5169 IntSize(video->videoWidth(), video->videoHeight()))); | 5186 IntSize(video->videoWidth(), video->videoHeight()))); |
| 5170 if (surface->isValid()) { | 5187 if (surface->isValid()) { |
| 5171 std::unique_ptr<ImageBuffer> imageBuffer( | 5188 std::unique_ptr<ImageBuffer> imageBuffer( |
| 5172 ImageBuffer::create(std::move(surface))); | 5189 ImageBuffer::create(std::move(surface))); |
| 5173 if (imageBuffer) { | 5190 if (imageBuffer) { |
| 5174 // The video element paints an RGBA frame into our surface here. By | 5191 // The video element paints an RGBA frame into our surface here. By |
| 5175 // using an AcceleratedImageBufferSurface, we enable the | 5192 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
| 5176 // WebMediaPlayer implementation to do any necessary color space | 5193 // implementation to do any necessary color space conversion on the GPU |
| 5177 // conversion on the GPU (though it | 5194 // (though it may still do a CPU conversion and upload the results). |
| 5178 // may still do a CPU conversion and upload the results). | 5195 video->paintCurrentFrame( |
| 5179 video->paintCurrentFrame( | 5196 imageBuffer->canvas(), |
| 5180 imageBuffer->canvas(), | 5197 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
| 5181 IntRect(0, 0, video->videoWidth(), video->videoHeight()), | |
| 5182 nullptr); | |
| 5183 | 5198 |
| 5184 // This is a straight GPU-GPU copy, any necessary color space | 5199 // This is a straight GPU-GPU copy, any necessary color space conversion |
| 5185 // conversion was handled in the paintCurrentFrameInContext() call. | 5200 // was handled in the paintCurrentFrameInContext() call. |
| 5186 | 5201 |
| 5187 // Note that copyToPlatformTexture no longer allocates the | 5202 // Note that copyToPlatformTexture no longer allocates the destination |
| 5188 // destination texture. | 5203 // texture. |
| 5189 texImage2DBase(target, level, internalformat, video->videoWidth(), | 5204 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5190 video->videoHeight(), 0, format, type, nullptr); | 5205 video->videoHeight(), 0, format, type, nullptr); |
| 5191 | 5206 |
| 5192 if (imageBuffer->copyToPlatformTexture( | 5207 if (imageBuffer->copyToPlatformTexture( |
| 5193 contextGL(), texture->object(), internalformat, type, level, | 5208 contextGL(), texture->object(), internalformat, type, level, |
| 5194 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5209 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
| 5195 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5210 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
| 5196 return; | 5211 return; |
| 5197 } | |
| 5198 } | 5212 } |
| 5199 } | 5213 } |
| 5200 } | 5214 } |
| 5201 } | 5215 } |
| 5202 | 5216 |
| 5217 { | |
| 5218 // Try using optimized CPU-GPU path for some formats: e.g. Y16 and Y8. It | |
| 5219 // leaves early for other formats or if frame is stored on GPU. | |
|
Ken Russell (switch to Gerrit)
2016/11/22 22:47:44
This now needs to take into consideration the fact
aleksandar.stojiljkovic
2016/11/22 23:21:06
Thanks. I'll do so.
aleksandar.stojiljkovic
2016/11/27 20:44:00
Done.
| |
| 5220 ScopedUnpackParametersResetRestore( | |
| 5221 this, m_unpackFlipY || m_unpackPremultiplyAlpha); | |
| 5222 if (video->texImageImpl( | |
| 5223 static_cast<WebMediaPlayer::TexImageFunctionID>(functionID), target, | |
| 5224 contextGL(), level, convertTexInternalFormat(internalformat, type), | |
| 5225 format, type, xoffset, yoffset, zoffset, m_unpackFlipY, | |
| 5226 m_unpackPremultiplyAlpha && | |
| 5227 m_unpackColorspaceConversion == GL_NONE)) | |
| 5228 return; | |
| 5229 } | |
| 5230 | |
| 5203 RefPtr<Image> image = videoFrameToImage(video); | 5231 RefPtr<Image> image = videoFrameToImage(video); |
| 5204 if (!image) | 5232 if (!image) |
| 5205 return; | 5233 return; |
| 5206 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5234 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
| 5207 zoffset, format, type, image.get(), | 5235 zoffset, format, type, image.get(), |
| 5208 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, | 5236 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, |
| 5209 m_unpackPremultiplyAlpha, sourceImageRect, depth, | 5237 m_unpackPremultiplyAlpha, sourceImageRect, depth, |
| 5210 unpackImageHeight); | 5238 unpackImageHeight); |
| 5211 } | 5239 } |
| 5212 | 5240 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5334 type, false, false, data)) || | 5362 type, false, false, data)) || |
| 5335 (isPixelDataRGBA && | 5363 (isPixelDataRGBA && |
| 5336 !WebGLImageConversion::extractImageData( | 5364 !WebGLImageConversion::extractImageData( |
| 5337 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, | 5365 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, |
| 5338 bitmap->size(), sourceSubRect, depth, unpackImageHeight, format, | 5366 bitmap->size(), sourceSubRect, depth, unpackImageHeight, format, |
| 5339 type, false, false, data))) { | 5367 type, false, false, data))) { |
| 5340 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 5368 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
| 5341 return; | 5369 return; |
| 5342 } | 5370 } |
| 5343 } | 5371 } |
| 5344 resetUnpackParameters(); | 5372 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 5345 if (functionID == TexImage2D) { | 5373 if (functionID == TexImage2D) { |
| 5346 texImage2DBase(target, level, internalformat, width, height, 0, format, | 5374 texImage2DBase(target, level, internalformat, width, height, 0, format, |
| 5347 type, needConversion ? data.data() : pixelDataPtr); | 5375 type, needConversion ? data.data() : pixelDataPtr); |
| 5348 } else if (functionID == TexSubImage2D) { | 5376 } else if (functionID == TexSubImage2D) { |
| 5349 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, | 5377 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, |
| 5350 format, type, | 5378 format, type, |
| 5351 needConversion ? data.data() : pixelDataPtr); | 5379 needConversion ? data.data() : pixelDataPtr); |
| 5352 } else if (functionID == TexImage3D) { | 5380 } else if (functionID == TexImage3D) { |
| 5353 contextGL()->TexImage3D(target, level, internalformat, width, height, depth, | 5381 contextGL()->TexImage3D(target, level, internalformat, width, height, depth, |
| 5354 0, format, type, | 5382 0, format, type, |
| 5355 needConversion ? data.data() : pixelDataPtr); | 5383 needConversion ? data.data() : pixelDataPtr); |
| 5356 } else { | 5384 } else { |
| 5357 DCHECK_EQ(functionID, TexSubImage3D); | 5385 DCHECK_EQ(functionID, TexSubImage3D); |
| 5358 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, | 5386 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, |
| 5359 height, depth, format, type, | 5387 height, depth, format, type, |
| 5360 needConversion ? data.data() : pixelDataPtr); | 5388 needConversion ? data.data() : pixelDataPtr); |
| 5361 } | 5389 } |
| 5362 restoreUnpackParameters(); | |
| 5363 } | 5390 } |
| 5364 | 5391 |
| 5365 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5392 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 5366 GLint level, | 5393 GLint level, |
| 5367 GLint internalformat, | 5394 GLint internalformat, |
| 5368 GLenum format, | 5395 GLenum format, |
| 5369 GLenum type, | 5396 GLenum type, |
| 5370 ImageBitmap* bitmap, | 5397 ImageBitmap* bitmap, |
| 5371 ExceptionState& exceptionState) { | 5398 ExceptionState& exceptionState) { |
| 5372 texImageHelperImageBitmap(TexImage2D, target, level, internalformat, format, | 5399 texImageHelperImageBitmap(TexImage2D, target, level, internalformat, format, |
| (...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7771 | 7798 |
| 7772 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7799 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7773 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7800 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7774 if (canvas()) | 7801 if (canvas()) |
| 7775 result.setHTMLCanvasElement(canvas()); | 7802 result.setHTMLCanvasElement(canvas()); |
| 7776 else | 7803 else |
| 7777 result.setOffscreenCanvas(getOffscreenCanvas()); | 7804 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7778 } | 7805 } |
| 7779 | 7806 |
| 7780 } // namespace blink | 7807 } // namespace blink |
| OLD | NEW |