| 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) |
| 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 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4409 if (!WebGLImageConversion::packImageData( | 4431 if (!WebGLImageConversion::packImageData( |
| 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, | 4434 imageExtractor.imageHeight(), adjustedSourceImageRect, |
| 4413 imageExtractor.imageSourceUnpackAlignment(), data)) { | 4435 imageExtractor.imageSourceUnpackAlignment(), data)) { |
| 4414 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); | 4436 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); |
| 4415 return; | 4437 return; |
| 4416 } | 4438 } |
| 4417 } | 4439 } |
| 4418 | 4440 |
| 4419 resetUnpackParameters(); | 4441 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 4420 if (functionID == TexImage2D) { | 4442 if (functionID == TexImage2D) { |
| 4421 texImage2DBase(target, level, internalformat, | 4443 texImage2DBase(target, level, internalformat, |
| 4422 adjustedSourceImageRect.width(), | 4444 adjustedSourceImageRect.width(), |
| 4423 adjustedSourceImageRect.height(), 0, format, type, | 4445 adjustedSourceImageRect.height(), 0, format, type, |
| 4424 needConversion ? data.data() : imagePixelData); | 4446 needConversion ? data.data() : imagePixelData); |
| 4425 } else if (functionID == TexSubImage2D) { | 4447 } else if (functionID == TexSubImage2D) { |
| 4426 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, | 4448 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, |
| 4427 adjustedSourceImageRect.width(), | 4449 adjustedSourceImageRect.width(), |
| 4428 adjustedSourceImageRect.height(), format, type, | 4450 adjustedSourceImageRect.height(), format, type, |
| 4429 needConversion ? data.data() : imagePixelData); | 4451 needConversion ? data.data() : imagePixelData); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4440 depth, 0, format, type, | 4462 depth, 0, format, type, |
| 4441 needConversion ? data.data() : imagePixelData); | 4463 needConversion ? data.data() : imagePixelData); |
| 4442 } else { | 4464 } else { |
| 4443 DCHECK_EQ(functionID, TexSubImage3D); | 4465 DCHECK_EQ(functionID, TexSubImage3D); |
| 4444 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 4466 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
| 4445 adjustedSourceImageRect.width(), uploadHeight, | 4467 adjustedSourceImageRect.width(), uploadHeight, |
| 4446 depth, format, type, | 4468 depth, format, type, |
| 4447 needConversion ? data.data() : imagePixelData); | 4469 needConversion ? data.data() : imagePixelData); |
| 4448 } | 4470 } |
| 4449 } | 4471 } |
| 4450 restoreUnpackParameters(); | |
| 4451 } | 4472 } |
| 4452 | 4473 |
| 4453 bool WebGLRenderingContextBase::validateTexFunc( | 4474 bool WebGLRenderingContextBase::validateTexFunc( |
| 4454 const char* functionName, | 4475 const char* functionName, |
| 4455 TexImageFunctionType functionType, | 4476 TexImageFunctionType functionType, |
| 4456 TexFuncValidationSourceType sourceType, | 4477 TexFuncValidationSourceType sourceType, |
| 4457 GLenum target, | 4478 GLenum target, |
| 4458 GLint level, | 4479 GLint level, |
| 4459 GLenum internalformat, | 4480 GLenum internalformat, |
| 4460 GLsizei width, | 4481 GLsizei width, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4646 convertTexInternalFormat(internalformat, type), | 4667 convertTexInternalFormat(internalformat, type), |
| 4647 width, height, depth, border, format, type, data); | 4668 width, height, depth, border, format, type, data); |
| 4648 return; | 4669 return; |
| 4649 } | 4670 } |
| 4650 if (functionID == TexSubImage3D) { | 4671 if (functionID == TexSubImage3D) { |
| 4651 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, | 4672 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, |
| 4652 height, depth, format, type, data); | 4673 height, depth, format, type, data); |
| 4653 return; | 4674 return; |
| 4654 } | 4675 } |
| 4655 | 4676 |
| 4656 if (changeUnpackAlignment) | 4677 ScopedUnpackParametersResetRestore temporaryResetUnpack( |
| 4657 resetUnpackParameters(); | 4678 this, changeUnpackAlignment); |
| 4658 if (functionID == TexImage2D) | 4679 if (functionID == TexImage2D) |
| 4659 texImage2DBase(target, level, internalformat, width, height, border, format, | 4680 texImage2DBase(target, level, internalformat, width, height, border, format, |
| 4660 type, data); | 4681 type, data); |
| 4661 else if (functionID == TexSubImage2D) | 4682 else if (functionID == TexSubImage2D) |
| 4662 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, | 4683 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, |
| 4663 format, type, data); | 4684 format, type, data); |
| 4664 if (changeUnpackAlignment) | |
| 4665 restoreUnpackParameters(); | |
| 4666 } | 4685 } |
| 4667 | 4686 |
| 4668 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4687 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 4669 GLint level, | 4688 GLint level, |
| 4670 GLint internalformat, | 4689 GLint internalformat, |
| 4671 GLsizei width, | 4690 GLsizei width, |
| 4672 GLsizei height, | 4691 GLsizei height, |
| 4673 GLint border, | 4692 GLint border, |
| 4674 GLenum format, | 4693 GLenum format, |
| 4675 GLenum type, | 4694 GLenum type, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4743 } | 4762 } |
| 4744 if (!WebGLImageConversion::extractImageData( | 4763 if (!WebGLImageConversion::extractImageData( |
| 4745 pixels->data()->data(), | 4764 pixels->data()->data(), |
| 4746 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), | 4765 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), |
| 4747 adjustedSourceImageRect, format, type, m_unpackFlipY, | 4766 adjustedSourceImageRect, format, type, m_unpackFlipY, |
| 4748 m_unpackPremultiplyAlpha, data)) { | 4767 m_unpackPremultiplyAlpha, data)) { |
| 4749 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 4768 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
| 4750 return; | 4769 return; |
| 4751 } | 4770 } |
| 4752 } | 4771 } |
| 4753 resetUnpackParameters(); | 4772 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 4754 const uint8_t* bytes = needConversion ? data.data() : pixels->data()->data(); | 4773 const uint8_t* bytes = needConversion ? data.data() : pixels->data()->data(); |
| 4755 if (functionID == TexImage2D) { | 4774 if (functionID == TexImage2D) { |
| 4756 DCHECK_EQ(unpackImageHeight, 0); | 4775 DCHECK_EQ(unpackImageHeight, 0); |
| 4757 texImage2DBase( | 4776 texImage2DBase( |
| 4758 target, level, internalformat, adjustedSourceImageRect.width(), | 4777 target, level, internalformat, adjustedSourceImageRect.width(), |
| 4759 adjustedSourceImageRect.height(), border, format, type, bytes); | 4778 adjustedSourceImageRect.height(), border, format, type, bytes); |
| 4760 } else if (functionID == TexSubImage2D) { | 4779 } else if (functionID == TexSubImage2D) { |
| 4761 DCHECK_EQ(unpackImageHeight, 0); | 4780 DCHECK_EQ(unpackImageHeight, 0); |
| 4762 contextGL()->TexSubImage2D( | 4781 contextGL()->TexSubImage2D( |
| 4763 target, level, xoffset, yoffset, adjustedSourceImageRect.width(), | 4782 target, level, xoffset, yoffset, adjustedSourceImageRect.width(), |
| 4764 adjustedSourceImageRect.height(), format, type, bytes); | 4783 adjustedSourceImageRect.height(), format, type, bytes); |
| 4765 } else { | 4784 } else { |
| 4766 GLint uploadHeight = adjustedSourceImageRect.height(); | 4785 GLint uploadHeight = adjustedSourceImageRect.height(); |
| 4767 if (unpackImageHeight) { | 4786 if (unpackImageHeight) { |
| 4768 // GL_UNPACK_IMAGE_HEIGHT overrides the passed-in height. | 4787 // GL_UNPACK_IMAGE_HEIGHT overrides the passed-in height. |
| 4769 uploadHeight = unpackImageHeight; | 4788 uploadHeight = unpackImageHeight; |
| 4770 } | 4789 } |
| 4771 if (functionID == TexImage3D) { | 4790 if (functionID == TexImage3D) { |
| 4772 contextGL()->TexImage3D(target, level, internalformat, | 4791 contextGL()->TexImage3D(target, level, internalformat, |
| 4773 adjustedSourceImageRect.width(), uploadHeight, | 4792 adjustedSourceImageRect.width(), uploadHeight, |
| 4774 depth, border, format, type, bytes); | 4793 depth, border, format, type, bytes); |
| 4775 } else { | 4794 } else { |
| 4776 DCHECK_EQ(functionID, TexSubImage3D); | 4795 DCHECK_EQ(functionID, TexSubImage3D); |
| 4777 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 4796 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
| 4778 adjustedSourceImageRect.width(), uploadHeight, | 4797 adjustedSourceImageRect.width(), uploadHeight, |
| 4779 depth, format, type, bytes); | 4798 depth, format, type, bytes); |
| 4780 } | 4799 } |
| 4781 } | 4800 } |
| 4782 restoreUnpackParameters(); | |
| 4783 } | 4801 } |
| 4784 | 4802 |
| 4785 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4803 void WebGLRenderingContextBase::texImage2D(GLenum target, |
| 4786 GLint level, | 4804 GLint level, |
| 4787 GLint internalformat, | 4805 GLint internalformat, |
| 4788 GLenum format, | 4806 GLenum format, |
| 4789 GLenum type, | 4807 GLenum type, |
| 4790 ImageData* pixels) { | 4808 ImageData* pixels) { |
| 4791 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, | 4809 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, |
| 4792 type, 1, 0, 0, 0, pixels, getImageDataSize(pixels), | 4810 type, 1, 0, 0, 0, pixels, getImageDataSize(pixels), |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5158 level, internalformat, video->videoWidth(), | 5176 level, internalformat, video->videoWidth(), |
| 5159 video->videoHeight(), 1, 0, format, type, xoffset, | 5177 video->videoHeight(), 1, 0, format, type, xoffset, |
| 5160 yoffset, zoffset)) | 5178 yoffset, zoffset)) |
| 5161 return; | 5179 return; |
| 5162 | 5180 |
| 5163 bool sourceImageRectIsDefault = | 5181 bool sourceImageRectIsDefault = |
| 5164 sourceImageRect == sentinelEmptyRect() || | 5182 sourceImageRect == sentinelEmptyRect() || |
| 5165 sourceImageRect == | 5183 sourceImageRect == |
| 5166 IntRect(0, 0, video->videoWidth(), video->videoHeight()); | 5184 IntRect(0, 0, video->videoWidth(), video->videoHeight()); |
| 5167 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && | 5185 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 && |
| 5168 unpackImageHeight == 0) { | 5186 unpackImageHeight == 0 && GL_TEXTURE_2D == target && |
| 5187 Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, |
| 5188 level)) { |
| 5169 DCHECK_EQ(xoffset, 0); | 5189 DCHECK_EQ(xoffset, 0); |
| 5170 DCHECK_EQ(yoffset, 0); | 5190 DCHECK_EQ(yoffset, 0); |
| 5171 DCHECK_EQ(zoffset, 0); | 5191 DCHECK_EQ(zoffset, 0); |
| 5172 // Go through the fast path doing a GPU-GPU textures copy without a readback | 5192 // Go through the fast path doing a GPU-GPU textures copy without a readback |
| 5173 // to system memory if possible. Otherwise, it will fall back to the normal | 5193 // to system memory if possible. Otherwise, it will fall back to the normal |
| 5174 // SW path. | 5194 // SW path. |
| 5175 if (GL_TEXTURE_2D == target) { | 5195 if (video->copyVideoTextureToPlatformTexture( |
| 5176 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, | 5196 contextGL(), texture->object(), internalformat, type, |
| 5177 type, level) && | 5197 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 5178 video->copyVideoTextureToPlatformTexture( | 5198 return; |
| 5179 contextGL(), texture->object(), internalformat, type, | 5199 } |
| 5180 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | |
| 5181 return; | |
| 5182 } | |
| 5183 | 5200 |
| 5184 // Try using an accelerated image buffer, this allows YUV conversion to be | 5201 // Try using an accelerated image buffer, this allows YUV conversion to be |
| 5185 // done on the GPU. | 5202 // done on the GPU. |
| 5186 std::unique_ptr<ImageBufferSurface> surface = | 5203 std::unique_ptr<ImageBufferSurface> surface = |
| 5187 wrapUnique(new AcceleratedImageBufferSurface( | 5204 wrapUnique(new AcceleratedImageBufferSurface( |
| 5188 IntSize(video->videoWidth(), video->videoHeight()))); | 5205 IntSize(video->videoWidth(), video->videoHeight()))); |
| 5189 if (surface->isValid()) { | 5206 if (surface->isValid()) { |
| 5190 std::unique_ptr<ImageBuffer> imageBuffer( | 5207 std::unique_ptr<ImageBuffer> imageBuffer( |
| 5191 ImageBuffer::create(std::move(surface))); | 5208 ImageBuffer::create(std::move(surface))); |
| 5192 if (imageBuffer) { | 5209 if (imageBuffer) { |
| 5193 // The video element paints an RGBA frame into our surface here. By | 5210 // The video element paints an RGBA frame into our surface here. By |
| 5194 // using an AcceleratedImageBufferSurface, we enable the | 5211 // using an AcceleratedImageBufferSurface, we enable the WebMediaPlayer |
| 5195 // WebMediaPlayer implementation to do any necessary color space | 5212 // implementation to do any necessary color space conversion on the GPU |
| 5196 // conversion on the GPU (though it | 5213 // (though it may still do a CPU conversion and upload the results). |
| 5197 // may still do a CPU conversion and upload the results). | 5214 video->paintCurrentFrame( |
| 5198 video->paintCurrentFrame( | 5215 imageBuffer->canvas(), |
| 5199 imageBuffer->canvas(), | 5216 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
| 5200 IntRect(0, 0, video->videoWidth(), video->videoHeight()), | |
| 5201 nullptr); | |
| 5202 | 5217 |
| 5203 // This is a straight GPU-GPU copy, any necessary color space | 5218 // This is a straight GPU-GPU copy, any necessary color space conversion |
| 5204 // conversion was handled in the paintCurrentFrameInContext() call. | 5219 // was handled in the paintCurrentFrameInContext() call. |
| 5205 | 5220 |
| 5206 // Note that copyToPlatformTexture no longer allocates the | 5221 // Note that copyToPlatformTexture no longer allocates the destination |
| 5207 // destination texture. | 5222 // texture. |
| 5208 texImage2DBase(target, level, internalformat, video->videoWidth(), | 5223 texImage2DBase(target, level, internalformat, video->videoWidth(), |
| 5209 video->videoHeight(), 0, format, type, nullptr); | 5224 video->videoHeight(), 0, format, type, nullptr); |
| 5210 | 5225 |
| 5211 if (imageBuffer->copyToPlatformTexture( | 5226 if (imageBuffer->copyToPlatformTexture( |
| 5212 contextGL(), texture->object(), internalformat, type, level, | 5227 contextGL(), texture->object(), internalformat, type, level, |
| 5213 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), | 5228 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), |
| 5214 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { | 5229 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { |
| 5215 return; | 5230 return; |
| 5216 } | |
| 5217 } | 5231 } |
| 5218 } | 5232 } |
| 5219 } | 5233 } |
| 5220 } | 5234 } |
| 5221 | 5235 |
| 5236 { |
| 5237 // Try using optimized CPU-GPU path for some formats: e.g. Y16 and Y8. It |
| 5238 // leaves early for other formats or if frame is stored on GPU. |
| 5239 ScopedUnpackParametersResetRestore( |
| 5240 this, m_unpackFlipY || m_unpackPremultiplyAlpha); |
| 5241 if (video->texImageImpl( |
| 5242 static_cast<WebMediaPlayer::TexImageFunctionID>(functionID), target, |
| 5243 contextGL(), level, convertTexInternalFormat(internalformat, type), |
| 5244 format, type, xoffset, yoffset, zoffset, m_unpackFlipY, |
| 5245 m_unpackPremultiplyAlpha && |
| 5246 m_unpackColorspaceConversion == GL_NONE)) |
| 5247 return; |
| 5248 } |
| 5249 |
| 5222 RefPtr<Image> image = videoFrameToImage(video); | 5250 RefPtr<Image> image = videoFrameToImage(video); |
| 5223 if (!image) | 5251 if (!image) |
| 5224 return; | 5252 return; |
| 5225 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5253 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
| 5226 zoffset, format, type, image.get(), | 5254 zoffset, format, type, image.get(), |
| 5227 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, | 5255 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, |
| 5228 m_unpackPremultiplyAlpha, sourceImageRect, depth, | 5256 m_unpackPremultiplyAlpha, sourceImageRect, depth, |
| 5229 unpackImageHeight); | 5257 unpackImageHeight); |
| 5230 } | 5258 } |
| 5231 | 5259 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5336 data)) || | 5364 data)) || |
| 5337 (isPixelDataRGBA && | 5365 (isPixelDataRGBA && |
| 5338 !WebGLImageConversion::extractImageData( | 5366 !WebGLImageConversion::extractImageData( |
| 5339 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, | 5367 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, |
| 5340 bitmap->size(), sourceImageRect, format, type, false, false, | 5368 bitmap->size(), sourceImageRect, format, type, false, false, |
| 5341 data))) { | 5369 data))) { |
| 5342 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 5370 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
| 5343 return; | 5371 return; |
| 5344 } | 5372 } |
| 5345 } | 5373 } |
| 5346 resetUnpackParameters(); | 5374 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
| 5347 if (functionID == TexImage2D) { | 5375 if (functionID == TexImage2D) { |
| 5348 texImage2DBase(target, level, internalformat, bitmap->width(), | 5376 texImage2DBase(target, level, internalformat, bitmap->width(), |
| 5349 bitmap->height(), 0, format, type, | 5377 bitmap->height(), 0, format, type, |
| 5350 needConversion ? data.data() : pixelDataPtr); | 5378 needConversion ? data.data() : pixelDataPtr); |
| 5351 } else if (functionID == TexSubImage2D) { | 5379 } else if (functionID == TexSubImage2D) { |
| 5352 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, bitmap->width(), | 5380 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, bitmap->width(), |
| 5353 bitmap->height(), format, type, | 5381 bitmap->height(), format, type, |
| 5354 needConversion ? data.data() : pixelDataPtr); | 5382 needConversion ? data.data() : pixelDataPtr); |
| 5355 } else { | 5383 } else { |
| 5356 DCHECK_EQ(functionID, TexSubImage3D); | 5384 DCHECK_EQ(functionID, TexSubImage3D); |
| 5357 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 5385 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
| 5358 bitmap->width(), bitmap->height(), 1, format, | 5386 bitmap->width(), bitmap->height(), 1, format, |
| 5359 type, | 5387 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 2396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7769 | 7796 |
| 7770 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7797 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7771 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7798 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7772 if (canvas()) | 7799 if (canvas()) |
| 7773 result.setHTMLCanvasElement(canvas()); | 7800 result.setHTMLCanvasElement(canvas()); |
| 7774 else | 7801 else |
| 7775 result.setOffscreenCanvas(getOffscreenCanvas()); | 7802 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7776 } | 7803 } |
| 7777 | 7804 |
| 7778 } // namespace blink | 7805 } // namespace blink |
| OLD | NEW |