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

Side by Side Diff: sky/engine/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 701663002: Remove HTMLVideoElement. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
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 16 matching lines...) Expand all
27 #include "core/html/canvas/WebGLRenderingContextBase.h" 27 #include "core/html/canvas/WebGLRenderingContextBase.h"
28 28
29 #include "bindings/core/v8/ExceptionMessages.h" 29 #include "bindings/core/v8/ExceptionMessages.h"
30 #include "bindings/core/v8/ExceptionState.h" 30 #include "bindings/core/v8/ExceptionState.h"
31 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
32 #include "core/fetch/ImageResource.h" 32 #include "core/fetch/ImageResource.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/frame/Settings.h" 34 #include "core/frame/Settings.h"
35 #include "core/html/HTMLCanvasElement.h" 35 #include "core/html/HTMLCanvasElement.h"
36 #include "core/html/HTMLImageElement.h" 36 #include "core/html/HTMLImageElement.h"
37 #include "core/html/HTMLVideoElement.h"
38 #include "core/html/ImageData.h" 37 #include "core/html/ImageData.h"
39 #include "core/html/canvas/ANGLEInstancedArrays.h" 38 #include "core/html/canvas/ANGLEInstancedArrays.h"
40 #include "core/html/canvas/EXTBlendMinMax.h" 39 #include "core/html/canvas/EXTBlendMinMax.h"
41 #include "core/html/canvas/EXTFragDepth.h" 40 #include "core/html/canvas/EXTFragDepth.h"
42 #include "core/html/canvas/EXTShaderTextureLOD.h" 41 #include "core/html/canvas/EXTShaderTextureLOD.h"
43 #include "core/html/canvas/EXTTextureFilterAnisotropic.h" 42 #include "core/html/canvas/EXTTextureFilterAnisotropic.h"
44 #include "core/html/canvas/OESElementIndexUint.h" 43 #include "core/html/canvas/OESElementIndexUint.h"
45 #include "core/html/canvas/OESStandardDerivatives.h" 44 #include "core/html/canvas/OESStandardDerivatives.h"
46 #include "core/html/canvas/OESTextureFloat.h" 45 #include "core/html/canvas/OESTextureFloat.h"
47 #include "core/html/canvas/OESTextureFloatLinear.h" 46 #include "core/html/canvas/OESTextureFloatLinear.h"
(...skipping 3488 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 } 3535 }
3537 } 3536 }
3538 3537
3539 RefPtr<ImageData> imageData = canvas->getImageData(); 3538 RefPtr<ImageData> imageData = canvas->getImageData();
3540 if (imageData) 3539 if (imageData)
3541 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState); 3540 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState);
3542 else 3541 else
3543 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip lyAlpha, exceptionState); 3542 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip lyAlpha, exceptionState);
3544 } 3543 }
3545 3544
3546 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy)
3547 {
3548 IntSize size(video->videoWidth(), video->videoHeight());
3549 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
3550 if (!buf) {
3551 synthesizeGLError(GL_OUT_OF_MEMORY, "texImage2D", "out of memory");
3552 return nullptr;
3553 }
3554 IntRect destRect(0, 0, size.width(), size.height());
3555 // FIXME: Turn this into a GPU-GPU texture copy instead of CPU readback.
3556 video->paintCurrentFrameInContext(buf->context(), destRect);
3557 return buf->copyImage(backingStoreCopy);
3558 }
3559
3560 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
3561 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState)
3562 {
3563 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except ionState)
3564 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 0, format, type, 0, 0))
3565 return;
3566
3567 // Go through the fast path doing a GPU-GPU textures copy without a readback to system memory if possible.
3568 // Otherwise, it will fall back to the normal SW path.
3569 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3570 if (GL_TEXTURE_2D == target && texture) {
3571 if (video->copyVideoTextureToPlatformTexture(webContext(), texture->obje ct(), level, internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3572 texture->setLevelInfo(target, level, internalformat, video->videoWid th(), video->videoHeight(), type);
3573 return;
3574 }
3575 }
3576
3577 // Normal pure SW path.
3578 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e());
3579 if (!image)
3580 return;
3581 texImage2DImpl(target, level, internalformat, format, type, image.get(), Web GLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, except ionState);
3582 }
3583
3584 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa t paramf, GLint parami, bool isFloat) 3545 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa t paramf, GLint parami, bool isFloat)
3585 { 3546 {
3586 if (isContextLost()) 3547 if (isContextLost())
3587 return; 3548 return;
3588 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); 3549 WebGLTexture* tex = validateTextureBinding("texParameter", target, false);
3589 if (!tex) 3550 if (!tex)
3590 return; 3551 return;
3591 switch (pname) { 3552 switch (pname) {
3592 case GL_TEXTURE_MIN_FILTER: 3553 case GL_TEXTURE_MIN_FILTER:
3593 case GL_TEXTURE_MAG_FILTER: 3554 case GL_TEXTURE_MAG_FILTER:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset)) 3713 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem ent, target, level, format, canvas->width(), canvas->height(), 0, format, type, xoffset, yoffset))
3753 return; 3714 return;
3754 3715
3755 RefPtr<ImageData> imageData = canvas->getImageData(); 3716 RefPtr<ImageData> imageData = canvas->getImageData();
3756 if (imageData) 3717 if (imageData)
3757 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.g et(), exceptionState); 3718 texSubImage2D(target, level, xoffset, yoffset, format, type, imageData.g et(), exceptionState);
3758 else 3719 else
3759 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPrem ultiplyAlpha, exceptionState); 3720 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas- >copiedImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPrem ultiplyAlpha, exceptionState);
3760 } 3721 }
3761 3722
3762 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
3763 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti onState)
3764 {
3765 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc eptionState)
3766 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme nt, target, level, format, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
3767 return;
3768
3769 RefPtr<Image> image = videoFrameToImage(video, ImageBuffer::fastCopyImageMod e());
3770 if (!image)
3771 return;
3772 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get() , WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha, e xceptionState);
3773 }
3774
3775 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, GLfloat x) 3723 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location, GLfloat x)
3776 { 3724 {
3777 if (isContextLost() || !location) 3725 if (isContextLost() || !location)
3778 return; 3726 return;
3779 3727
3780 if (location->program() != m_currentProgram) { 3728 if (location->program() != m_currentProgram) {
3781 synthesizeGLError(GL_INVALID_OPERATION, "uniform1f", "location not for c urrent program"); 3729 synthesizeGLError(GL_INVALID_OPERATION, "uniform1f", "location not for c urrent program");
3782 return; 3730 return;
3783 } 3731 }
3784 3732
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
5255 5203
5256 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionNa me, HTMLCanvasElement* canvas, ExceptionState& exceptionState) 5204 bool WebGLRenderingContextBase::validateHTMLCanvasElement(const char* functionNa me, HTMLCanvasElement* canvas, ExceptionState& exceptionState)
5257 { 5205 {
5258 if (!canvas || !canvas->buffer()) { 5206 if (!canvas || !canvas->buffer()) {
5259 synthesizeGLError(GL_INVALID_VALUE, functionName, "no canvas"); 5207 synthesizeGLError(GL_INVALID_VALUE, functionName, "no canvas");
5260 return false; 5208 return false;
5261 } 5209 }
5262 return true; 5210 return true;
5263 } 5211 }
5264 5212
5265 bool WebGLRenderingContextBase::validateHTMLVideoElement(const char* functionNam e, HTMLVideoElement* video, ExceptionState& exceptionState)
5266 {
5267 if (!video || !video->videoWidth() || !video->videoHeight()) {
5268 synthesizeGLError(GL_INVALID_VALUE, functionName, "no video");
5269 return false;
5270 }
5271 return true;
5272 }
5273
5274 bool WebGLRenderingContextBase::validateDrawArrays(const char* functionName, GLe num mode, GLint first, GLsizei count) 5213 bool WebGLRenderingContextBase::validateDrawArrays(const char* functionName, GLe num mode, GLint first, GLsizei count)
5275 { 5214 {
5276 if (isContextLost() || !validateDrawMode(functionName, mode)) 5215 if (isContextLost() || !validateDrawMode(functionName, mode))
5277 return false; 5216 return false;
5278 5217
5279 if (!validateStencilSettings(functionName)) 5218 if (!validateStencilSettings(functionName))
5280 return false; 5219 return false;
5281 5220
5282 if (first < 0 || count < 0) { 5221 if (first < 0 || count < 0) {
5283 synthesizeGLError(GL_INVALID_VALUE, functionName, "first or count < 0"); 5222 synthesizeGLError(GL_INVALID_VALUE, functionName, "first or count < 0");
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
5740 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 5679 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
5741 } 5680 }
5742 #else 5681 #else
5743 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 5682 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
5744 { 5683 {
5745 return m_drawingBuffer.get(); 5684 return m_drawingBuffer.get();
5746 } 5685 }
5747 #endif 5686 #endif
5748 5687
5749 } // namespace blink 5688 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/html/canvas/WebGLRenderingContextBase.h ('k') | sky/engine/core/html/canvas/WebGLRenderingContextBase.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698