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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 public: | 493 public: |
494 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context) | 494 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context) |
495 : m_context(context) {} | 495 : m_context(context) {} |
496 | 496 |
497 ~ScopedFramebufferRestorer() { m_context->restoreCurrentFramebuffer(); } | 497 ~ScopedFramebufferRestorer() { m_context->restoreCurrentFramebuffer(); } |
498 | 498 |
499 private: | 499 private: |
500 Member<WebGLRenderingContextBase> m_context; | 500 Member<WebGLRenderingContextBase> m_context; |
501 }; | 501 }; |
502 | 502 |
| 503 class ScopedUnpackParametersResetRestore { |
| 504 STACK_ALLOCATED(); |
| 505 |
| 506 public: |
| 507 explicit ScopedUnpackParametersResetRestore( |
| 508 WebGLRenderingContextBase* context, |
| 509 bool enabled = true) |
| 510 : m_context(context), m_enabled(enabled) { |
| 511 if (enabled) |
| 512 m_context->resetUnpackParameters(); |
| 513 } |
| 514 |
| 515 ~ScopedUnpackParametersResetRestore() { |
| 516 if (m_enabled) |
| 517 m_context->restoreUnpackParameters(); |
| 518 } |
| 519 |
| 520 private: |
| 521 Member<WebGLRenderingContextBase> m_context; |
| 522 bool m_enabled; |
| 523 }; |
| 524 |
503 static void formatWebGLStatusString(const StringView& glInfo, | 525 static void formatWebGLStatusString(const StringView& glInfo, |
504 const StringView& infoString, | 526 const StringView& infoString, |
505 StringBuilder& builder) { | 527 StringBuilder& builder) { |
506 if (infoString.isEmpty()) | 528 if (infoString.isEmpty()) |
507 return; | 529 return; |
508 builder.append(", "); | 530 builder.append(", "); |
509 builder.append(glInfo); | 531 builder.append(glInfo); |
510 builder.append(" = "); | 532 builder.append(" = "); |
511 builder.append(infoString); | 533 builder.append(infoString); |
512 } | 534 } |
(...skipping 3827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4340 if (!WebGLImageConversion::packImageData( | 4362 if (!WebGLImageConversion::packImageData( |
4341 image, imagePixelData, format, type, flipY, alphaOp, | 4363 image, imagePixelData, format, type, flipY, alphaOp, |
4342 sourceDataFormat, imageExtractor.imageWidth(), | 4364 sourceDataFormat, imageExtractor.imageWidth(), |
4343 imageExtractor.imageHeight(), | 4365 imageExtractor.imageHeight(), |
4344 imageExtractor.imageSourceUnpackAlignment(), data)) { | 4366 imageExtractor.imageSourceUnpackAlignment(), data)) { |
4345 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); | 4367 synthesizeGLError(GL_INVALID_VALUE, funcName, "packImage error"); |
4346 return; | 4368 return; |
4347 } | 4369 } |
4348 } | 4370 } |
4349 | 4371 |
4350 resetUnpackParameters(); | 4372 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
4351 if (functionID == TexImage2D) { | 4373 if (functionID == TexImage2D) { |
4352 texImage2DBase(target, level, internalformat, imageExtractor.imageWidth(), | 4374 texImage2DBase(target, level, internalformat, imageExtractor.imageWidth(), |
4353 imageExtractor.imageHeight(), 0, format, type, | 4375 imageExtractor.imageHeight(), 0, format, type, |
4354 needConversion ? data.data() : imagePixelData); | 4376 needConversion ? data.data() : imagePixelData); |
4355 } else if (functionID == TexSubImage2D) { | 4377 } else if (functionID == TexSubImage2D) { |
4356 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, | 4378 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, |
4357 imageExtractor.imageWidth(), | 4379 imageExtractor.imageWidth(), |
4358 imageExtractor.imageHeight(), format, type, | 4380 imageExtractor.imageHeight(), format, type, |
4359 needConversion ? data.data() : imagePixelData); | 4381 needConversion ? data.data() : imagePixelData); |
4360 } else { | 4382 } else { |
4361 DCHECK_EQ(functionID, TexSubImage3D); | 4383 DCHECK_EQ(functionID, TexSubImage3D); |
4362 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 4384 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
4363 imageExtractor.imageWidth(), | 4385 imageExtractor.imageWidth(), |
4364 imageExtractor.imageHeight(), 1, format, type, | 4386 imageExtractor.imageHeight(), 1, format, type, |
4365 needConversion ? data.data() : imagePixelData); | 4387 needConversion ? data.data() : imagePixelData); |
4366 } | 4388 } |
4367 restoreUnpackParameters(); | |
4368 } | 4389 } |
4369 | 4390 |
4370 bool WebGLRenderingContextBase::validateTexFunc( | 4391 bool WebGLRenderingContextBase::validateTexFunc( |
4371 const char* functionName, | 4392 const char* functionName, |
4372 TexImageFunctionType functionType, | 4393 TexImageFunctionType functionType, |
4373 TexFuncValidationSourceType sourceType, | 4394 TexFuncValidationSourceType sourceType, |
4374 GLenum target, | 4395 GLenum target, |
4375 GLint level, | 4396 GLint level, |
4376 GLenum internalformat, | 4397 GLenum internalformat, |
4377 GLsizei width, | 4398 GLsizei width, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4542 convertTexInternalFormat(internalformat, type), | 4563 convertTexInternalFormat(internalformat, type), |
4543 width, height, depth, border, format, type, data); | 4564 width, height, depth, border, format, type, data); |
4544 return; | 4565 return; |
4545 } | 4566 } |
4546 if (functionID == TexSubImage3D) { | 4567 if (functionID == TexSubImage3D) { |
4547 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, | 4568 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, |
4548 height, depth, format, type, data); | 4569 height, depth, format, type, data); |
4549 return; | 4570 return; |
4550 } | 4571 } |
4551 | 4572 |
4552 if (changeUnpackAlignment) | 4573 ScopedUnpackParametersResetRestore temporaryResetUnpack( |
4553 resetUnpackParameters(); | 4574 this, changeUnpackAlignment); |
4554 if (functionID == TexImage2D) | 4575 if (functionID == TexImage2D) |
4555 texImage2DBase(target, level, internalformat, width, height, border, format, | 4576 texImage2DBase(target, level, internalformat, width, height, border, format, |
4556 type, data); | 4577 type, data); |
4557 else if (functionID == TexSubImage2D) | 4578 else if (functionID == TexSubImage2D) |
4558 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, | 4579 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, width, height, |
4559 format, type, data); | 4580 format, type, data); |
4560 if (changeUnpackAlignment) | |
4561 restoreUnpackParameters(); | |
4562 } | 4581 } |
4563 | 4582 |
4564 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4583 void WebGLRenderingContextBase::texImage2D(GLenum target, |
4565 GLint level, | 4584 GLint level, |
4566 GLint internalformat, | 4585 GLint internalformat, |
4567 GLsizei width, | 4586 GLsizei width, |
4568 GLsizei height, | 4587 GLsizei height, |
4569 GLint border, | 4588 GLint border, |
4570 GLenum format, | 4589 GLenum format, |
4571 GLenum type, | 4590 GLenum type, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4624 type = GL_FLOAT; | 4643 type = GL_FLOAT; |
4625 } | 4644 } |
4626 if (!WebGLImageConversion::extractImageData( | 4645 if (!WebGLImageConversion::extractImageData( |
4627 pixels->data()->data(), | 4646 pixels->data()->data(), |
4628 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), | 4647 WebGLImageConversion::DataFormat::DataFormatRGBA8, pixels->size(), |
4629 format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { | 4648 format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { |
4630 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 4649 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
4631 return; | 4650 return; |
4632 } | 4651 } |
4633 } | 4652 } |
4634 resetUnpackParameters(); | 4653 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
4635 if (functionID == TexImage2D) { | 4654 if (functionID == TexImage2D) { |
4636 texImage2DBase(target, level, internalformat, pixels->width(), | 4655 texImage2DBase(target, level, internalformat, pixels->width(), |
4637 pixels->height(), border, format, type, | 4656 pixels->height(), border, format, type, |
4638 needConversion ? data.data() : pixels->data()->data()); | 4657 needConversion ? data.data() : pixels->data()->data()); |
4639 } else if (functionID == TexSubImage2D) { | 4658 } else if (functionID == TexSubImage2D) { |
4640 contextGL()->TexSubImage2D( | 4659 contextGL()->TexSubImage2D( |
4641 target, level, xoffset, yoffset, pixels->width(), pixels->height(), | 4660 target, level, xoffset, yoffset, pixels->width(), pixels->height(), |
4642 format, type, needConversion ? data.data() : pixels->data()->data()); | 4661 format, type, needConversion ? data.data() : pixels->data()->data()); |
4643 } else { | 4662 } else { |
4644 DCHECK_EQ(functionID, TexSubImage3D); | 4663 DCHECK_EQ(functionID, TexSubImage3D); |
4645 contextGL()->TexSubImage3D( | 4664 contextGL()->TexSubImage3D( |
4646 target, level, xoffset, yoffset, zoffset, pixels->width(), | 4665 target, level, xoffset, yoffset, zoffset, pixels->width(), |
4647 pixels->height(), depth, format, type, | 4666 pixels->height(), depth, format, type, |
4648 needConversion ? data.data() : pixels->data()->data()); | 4667 needConversion ? data.data() : pixels->data()->data()); |
4649 } | 4668 } |
4650 restoreUnpackParameters(); | |
4651 } | 4669 } |
4652 | 4670 |
4653 void WebGLRenderingContextBase::texImage2D(GLenum target, | 4671 void WebGLRenderingContextBase::texImage2D(GLenum target, |
4654 GLint level, | 4672 GLint level, |
4655 GLint internalformat, | 4673 GLint internalformat, |
4656 GLenum format, | 4674 GLenum format, |
4657 GLenum type, | 4675 GLenum type, |
4658 ImageData* pixels) { | 4676 ImageData* pixels) { |
4659 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, | 4677 texImageHelperImageData(TexImage2D, target, level, internalformat, 0, format, |
4660 type, 1, 0, 0, 0, pixels); | 4678 type, 1, 0, 0, 0, pixels); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4732 } | 4750 } |
4733 | 4751 |
4734 void WebGLRenderingContextBase::texImageCanvasByGPU(HTMLCanvasElement* canvas, | 4752 void WebGLRenderingContextBase::texImageCanvasByGPU(HTMLCanvasElement* canvas, |
4735 GLuint targetTexture, | 4753 GLuint targetTexture, |
4736 GLenum targetInternalformat, | 4754 GLenum targetInternalformat, |
4737 GLenum targetType, | 4755 GLenum targetType, |
4738 GLint targetLevel) { | 4756 GLint targetLevel) { |
4739 if (!canvas->is3D()) { | 4757 if (!canvas->is3D()) { |
4740 ImageBuffer* buffer = canvas->buffer(); | 4758 ImageBuffer* buffer = canvas->buffer(); |
4741 if (buffer && | 4759 if (buffer && |
| 4760 extensionsUtil()->canUseCopyTextureCHROMIUM( |
| 4761 targetTexture, targetInternalformat, targetType, targetLevel) && |
4742 !buffer->copyToPlatformTexture( | 4762 !buffer->copyToPlatformTexture( |
4743 contextGL(), targetTexture, targetInternalformat, targetType, | 4763 contextGL(), targetTexture, targetInternalformat, targetType, |
4744 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4764 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4745 NOTREACHED(); | 4765 NOTREACHED(); |
4746 } | 4766 } |
4747 } else { | 4767 } else { |
4748 WebGLRenderingContextBase* gl = | 4768 WebGLRenderingContextBase* gl = |
4749 toWebGLRenderingContextBase(canvas->renderingContext()); | 4769 toWebGLRenderingContextBase(canvas->renderingContext()); |
4750 ScopedTexture2DRestorer restorer(gl); | 4770 ScopedTexture2DRestorer restorer(gl); |
4751 if (!gl->drawingBuffer()->copyToPlatformTexture( | 4771 if (!gl->drawingBuffer()->copyToPlatformTexture( |
(...skipping 20 matching lines...) Expand all Loading... |
4772 int height = image->sourceHeight(); | 4792 int height = image->sourceHeight(); |
4773 | 4793 |
4774 ScopedTexture2DRestorer restorer(this); | 4794 ScopedTexture2DRestorer restorer(this); |
4775 | 4795 |
4776 GLuint targetTexture = texture->object(); | 4796 GLuint targetTexture = texture->object(); |
4777 GLenum targetType = type; | 4797 GLenum targetType = type; |
4778 GLenum targetInternalformat = internalformat; | 4798 GLenum targetInternalformat = internalformat; |
4779 GLint targetLevel = level; | 4799 GLint targetLevel = level; |
4780 bool possibleDirectCopy = false; | 4800 bool possibleDirectCopy = false; |
4781 if (functionType == TexImage2DByGPU) { | 4801 if (functionType == TexImage2DByGPU) { |
4782 possibleDirectCopy = Extensions3DUtil::canUseCopyTextureCHROMIUM( | 4802 possibleDirectCopy = extensionsUtil()->canUseCopyTextureCHROMIUM( |
4783 target, internalformat, type, level); | 4803 target, internalformat, type, level); |
4784 } | 4804 } |
4785 | 4805 |
4786 // if direct copy is not possible, create a temporary texture and then copy fr
om canvas to temporary texture to target texture. | 4806 // if direct copy is not possible, create a temporary texture and then copy fr
om canvas to temporary texture to target texture. |
4787 if (!possibleDirectCopy) { | 4807 if (!possibleDirectCopy) { |
4788 targetLevel = 0; | 4808 targetLevel = 0; |
4789 targetInternalformat = GL_RGBA; | 4809 targetInternalformat = GL_RGBA; |
4790 targetType = GL_UNSIGNED_BYTE; | 4810 targetType = GL_UNSIGNED_BYTE; |
4791 contextGL()->GenTextures(1, &targetTexture); | 4811 contextGL()->GenTextures(1, &targetTexture); |
4792 contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); | 4812 contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4947 if (functionID == TexImage2D) | 4967 if (functionID == TexImage2D) |
4948 functionType = TexImage; | 4968 functionType = TexImage; |
4949 else | 4969 else |
4950 functionType = TexSubImage; | 4970 functionType = TexSubImage; |
4951 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, | 4971 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, |
4952 level, internalformat, video->videoWidth(), | 4972 level, internalformat, video->videoWidth(), |
4953 video->videoHeight(), 1, 0, format, type, xoffset, | 4973 video->videoHeight(), 1, 0, format, type, xoffset, |
4954 yoffset, zoffset)) | 4974 yoffset, zoffset)) |
4955 return; | 4975 return; |
4956 | 4976 |
4957 if (functionID == TexImage2D) { | 4977 if (functionID == TexImage2D && GL_TEXTURE_2D == target && |
| 4978 extensionsUtil()->canUseCopyTextureCHROMIUM(target, internalformat, type, |
| 4979 level)) { |
4958 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 4980 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
4959 // Otherwise, it will fall back to the normal SW path. | 4981 // Otherwise, it will fall back to the normal SW path. |
4960 if (GL_TEXTURE_2D == target) { | 4982 if (video->copyVideoTextureToPlatformTexture( |
4961 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, | 4983 contextGL(), texture->object(), internalformat, type, |
4962 type, level) && | 4984 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4963 video->copyVideoTextureToPlatformTexture( | 4985 return; |
4964 contextGL(), texture->object(), internalformat, type, | 4986 } |
4965 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4987 } |
4966 return; | |
4967 } | |
4968 | 4988 |
4969 // Try using an accelerated image buffer, this allows YUV conversion to be
done on the GPU. | 4989 { |
4970 std::unique_ptr<ImageBufferSurface> surface = | 4990 // Try using optimized CPU-GPU path for some formats: e.g. Y16 and Y8. It le
aves early for other formats or if frame is stored on GPU. |
4971 wrapUnique(new AcceleratedImageBufferSurface( | 4991 ScopedUnpackParametersResetRestore( |
4972 IntSize(video->videoWidth(), video->videoHeight()))); | 4992 this, m_unpackFlipY || m_unpackPremultiplyAlpha); |
4973 if (surface->isValid()) { | 4993 if (video->texImageImpl(getTexImageFunctionName(functionID), target, |
4974 std::unique_ptr<ImageBuffer> imageBuffer( | 4994 contextGL(), level, internalformat, format, type, |
4975 ImageBuffer::create(std::move(surface))); | 4995 xoffset, yoffset, zoffset, m_unpackFlipY, |
4976 if (imageBuffer) { | 4996 m_unpackPremultiplyAlpha && |
4977 // The video element paints an RGBA frame into our surface here. By us
ing an AcceleratedImageBufferSurface, | 4997 m_unpackColorspaceConversion == GL_NONE)) |
4978 // we enable the WebMediaPlayer implementation to do any necessary col
or space conversion on the GPU (though it | 4998 return; |
4979 // may still do a CPU conversion and upload the results). | 4999 } |
4980 video->paintCurrentFrame( | |
4981 imageBuffer->canvas(), | |
4982 IntRect(0, 0, video->videoWidth(), video->videoHeight()), | |
4983 nullptr); | |
4984 | 5000 |
4985 // This is a straight GPU-GPU copy, any necessary color space conversi
on was handled in the paintCurrentFrameInContext() call. | 5001 if (functionID == TexImage2D && GL_TEXTURE_2D == target && |
4986 if (imageBuffer->copyToPlatformTexture( | 5002 extensionsUtil()->canUseCopyTextureCHROMIUM(target, internalformat, type, |
4987 contextGL(), texture->object(), internalformat, type, level, | 5003 level)) { |
4988 m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 5004 // Try using an accelerated image buffer, this allows YUV conversion to be d
one on the GPU. |
4989 return; | 5005 std::unique_ptr<ImageBufferSurface> surface = |
4990 } | 5006 wrapUnique(new AcceleratedImageBufferSurface( |
| 5007 IntSize(video->videoWidth(), video->videoHeight()))); |
| 5008 if (surface->isValid()) { |
| 5009 std::unique_ptr<ImageBuffer> imageBuffer( |
| 5010 ImageBuffer::create(std::move(surface))); |
| 5011 if (imageBuffer) { |
| 5012 // The video element paints an RGBA frame into our surface here. By usin
g an AcceleratedImageBufferSurface, |
| 5013 // we enable the WebMediaPlayer implementation to do any necessary color
space conversion on the GPU (though it |
| 5014 // may still do a CPU conversion and upload the results). |
| 5015 video->paintCurrentFrame( |
| 5016 imageBuffer->canvas(), |
| 5017 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr); |
| 5018 |
| 5019 // This is a straight GPU-GPU copy, any necessary color space conversion
was handled in the paintCurrentFrameInContext() call. |
| 5020 if (imageBuffer->copyToPlatformTexture( |
| 5021 contextGL(), texture->object(), internalformat, type, level, |
| 5022 m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
| 5023 return; |
4991 } | 5024 } |
4992 } | 5025 } |
4993 } | 5026 } |
4994 } | 5027 } |
4995 | 5028 |
4996 RefPtr<Image> image = videoFrameToImage(video); | 5029 RefPtr<Image> image = videoFrameToImage(video); |
4997 if (!image) | 5030 if (!image) |
4998 return; | 5031 return; |
4999 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, | 5032 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, |
5000 zoffset, format, type, image.get(), | 5033 zoffset, format, type, image.get(), |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5103 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatBGRA8, | 5136 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatBGRA8, |
5104 bitmap->size(), format, type, false, false, data)) || | 5137 bitmap->size(), format, type, false, false, data)) || |
5105 (isPixelDataRGBA && | 5138 (isPixelDataRGBA && |
5106 !WebGLImageConversion::extractImageData( | 5139 !WebGLImageConversion::extractImageData( |
5107 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, | 5140 pixelDataPtr, WebGLImageConversion::DataFormat::DataFormatRGBA8, |
5108 bitmap->size(), format, type, false, false, data))) { | 5141 bitmap->size(), format, type, false, false, data))) { |
5109 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); | 5142 synthesizeGLError(GL_INVALID_VALUE, funcName, "bad image data"); |
5110 return; | 5143 return; |
5111 } | 5144 } |
5112 } | 5145 } |
5113 resetUnpackParameters(); | 5146 ScopedUnpackParametersResetRestore temporaryResetUnpack(this); |
5114 if (functionID == TexImage2D) { | 5147 if (functionID == TexImage2D) { |
5115 texImage2DBase(target, level, internalformat, bitmap->width(), | 5148 texImage2DBase(target, level, internalformat, bitmap->width(), |
5116 bitmap->height(), 0, format, type, | 5149 bitmap->height(), 0, format, type, |
5117 needConversion ? data.data() : pixelDataPtr); | 5150 needConversion ? data.data() : pixelDataPtr); |
5118 } else if (functionID == TexSubImage2D) { | 5151 } else if (functionID == TexSubImage2D) { |
5119 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, bitmap->width(), | 5152 contextGL()->TexSubImage2D(target, level, xoffset, yoffset, bitmap->width(), |
5120 bitmap->height(), format, type, | 5153 bitmap->height(), format, type, |
5121 needConversion ? data.data() : pixelDataPtr); | 5154 needConversion ? data.data() : pixelDataPtr); |
5122 } else { | 5155 } else { |
5123 DCHECK_EQ(functionID, TexSubImage3D); | 5156 DCHECK_EQ(functionID, TexSubImage3D); |
5124 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, | 5157 contextGL()->TexSubImage3D(target, level, xoffset, yoffset, zoffset, |
5125 bitmap->width(), bitmap->height(), 1, format, | 5158 bitmap->width(), bitmap->height(), 1, format, |
5126 type, | 5159 type, |
5127 needConversion ? data.data() : pixelDataPtr); | 5160 needConversion ? data.data() : pixelDataPtr); |
5128 } | 5161 } |
5129 restoreUnpackParameters(); | |
5130 } | 5162 } |
5131 | 5163 |
5132 void WebGLRenderingContextBase::texImage2D(GLenum target, | 5164 void WebGLRenderingContextBase::texImage2D(GLenum target, |
5133 GLint level, | 5165 GLint level, |
5134 GLint internalformat, | 5166 GLint internalformat, |
5135 GLenum format, | 5167 GLenum format, |
5136 GLenum type, | 5168 GLenum type, |
5137 ImageBitmap* bitmap, | 5169 ImageBitmap* bitmap, |
5138 ExceptionState& exceptionState) { | 5170 ExceptionState& exceptionState) { |
5139 texImageHelperImageBitmap(TexImage2D, target, level, internalformat, format, | 5171 texImageHelperImageBitmap(TexImage2D, target, level, internalformat, format, |
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7428 | 7460 |
7429 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7461 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7430 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7462 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7431 if (canvas()) | 7463 if (canvas()) |
7432 result.setHTMLCanvasElement(canvas()); | 7464 result.setHTMLCanvasElement(canvas()); |
7433 else | 7465 else |
7434 result.setOffscreenCanvas(getOffscreenCanvas()); | 7466 result.setOffscreenCanvas(getOffscreenCanvas()); |
7435 } | 7467 } |
7436 | 7468 |
7437 } // namespace blink | 7469 } // namespace blink |
OLD | NEW |