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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1817323003: Revert of Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: Created 4 years, 9 months 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 4078 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 bool possibleDirectCopy = false; 4089 bool possibleDirectCopy = false;
4090 if (functionType == TexImage2DByGPU) { 4090 if (functionType == TexImage2DByGPU) {
4091 possibleDirectCopy = Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level); 4091 possibleDirectCopy = Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, type, level);
4092 } 4092 }
4093 4093
4094 // if direct copy is not possible, create a temporary texture and then copy from canvas to temporary texture to target texture. 4094 // if direct copy is not possible, create a temporary texture and then copy from canvas to temporary texture to target texture.
4095 if (!possibleDirectCopy) { 4095 if (!possibleDirectCopy) {
4096 targetLevel = 0; 4096 targetLevel = 0;
4097 targetInternalformat = GL_RGBA; 4097 targetInternalformat = GL_RGBA;
4098 targetType = GL_UNSIGNED_BYTE; 4098 targetType = GL_UNSIGNED_BYTE;
4099 contextGL()->GenTextures(1, &targetTexture); 4099 targetTexture = webContext()->createTexture();
4100 contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture); 4100 contextGL()->BindTexture(GL_TEXTURE_2D, targetTexture);
4101 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAR EST); 4101 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAR EST);
4102 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAR EST); 4102 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAR EST);
4103 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO _EDGE); 4103 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO _EDGE);
4104 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO _EDGE); 4104 contextGL()->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO _EDGE);
4105 contextGL()->TexImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-> width(), 4105 contextGL()->TexImage2D(GL_TEXTURE_2D, 0, targetInternalformat, canvas-> width(),
4106 canvas->height(), 0, GL_RGBA, targetType, 0); 4106 canvas->height(), 0, GL_RGBA, targetType, 0);
4107 } 4107 }
4108 4108
4109 if (!canvas->is3D()) { 4109 if (!canvas->is3D()) {
4110 ImageBuffer* buffer = canvas->buffer(); 4110 ImageBuffer* buffer = canvas->buffer();
4111 if (!buffer->copyToPlatformTexture(webContext(), contextGL(), targetText ure, targetInternalformat, targetType, 4111 if (!buffer->copyToPlatformTexture(webContext(), contextGL(), targetText ure, targetInternalformat, targetType,
4112 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 4112 targetLevel, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
4113 ASSERT_NOT_REACHED(); 4113 ASSERT_NOT_REACHED();
4114 } 4114 }
4115 } else { 4115 } else {
4116 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend eringContext()); 4116 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas->rend eringContext());
4117 ScopedTexture2DRestorer restorer(gl); 4117 ScopedTexture2DRestorer restorer(gl);
4118 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), contextGL( ), targetTexture, targetInternalformat, targetType, 4118 if (!gl->drawingBuffer()->copyToPlatformTexture(webContext(), contextGL( ), targetTexture, targetInternalformat, targetType,
4119 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer)) { 4119 targetLevel, m_unpackPremultiplyAlpha, !m_unpackFlipY, BackBuffer)) {
4120 ASSERT_NOT_REACHED(); 4120 ASSERT_NOT_REACHED();
4121 } 4121 }
4122 } 4122 }
4123 4123
4124 if (!possibleDirectCopy) { 4124 if (!possibleDirectCopy) {
4125 GLuint tmpFBO; 4125 WebGLId tmpFBO = webContext()->createFramebuffer();
4126 contextGL()->GenFramebuffers(1, &tmpFBO);
4127 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO); 4126 contextGL()->BindFramebuffer(GL_FRAMEBUFFER, tmpFBO);
4128 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0); 4127 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0);
4129 contextGL()->BindTexture(texture->getTarget(), texture->object()); 4128 contextGL()->BindTexture(texture->getTarget(), texture->object());
4130 if (functionType == TexImage2DByGPU) { 4129 if (functionType == TexImage2DByGPU) {
4131 contextGL()->CopyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->wi dth(), canvas->height()); 4130 contextGL()->CopyTexSubImage2D(target, level, 0, 0, 0, 0, canvas->wi dth(), canvas->height());
4132 } else if (functionType == TexSubImage2DByGPU) { 4131 } else if (functionType == TexSubImage2DByGPU) {
4133 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, 0, 0 , canvas->width(), canvas->height()); 4132 contextGL()->CopyTexSubImage2D(target, level, xoffset, yoffset, 0, 0 , canvas->width(), canvas->height());
4134 } else if (functionType == TexSubImage3DByGPU) { 4133 } else if (functionType == TexSubImage3DByGPU) {
4135 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof fset, 0, 0, canvas->width(), canvas->height()); 4134 webContext()->copyTexSubImage3D(target, level, xoffset, yoffset, zof fset, 0, 0, canvas->width(), canvas->height());
4136 } 4135 }
4137 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 4136 contextGL()->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
4138 restoreCurrentFramebuffer(); 4137 restoreCurrentFramebuffer();
4139 contextGL()->DeleteFramebuffers(1, &tmpFBO); 4138 webContext()->deleteFramebuffer(tmpFBO);
4140 contextGL()->DeleteTextures(1, &targetTexture); 4139 webContext()->deleteTexture(targetTexture);
4141 } 4140 }
4142 } 4141 }
4143 4142
4144 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat, 4143 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLint int ernalformat,
4145 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) 4144 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState)
4146 { 4145 {
4147 if (isContextLost()) 4146 if (isContextLost())
4148 return; 4147 return;
4149 if (!validateHTMLCanvasElement("texImage2D", canvas, exceptionState)) 4148 if (!validateHTMLCanvasElement("texImage2D", canvas, exceptionState))
4150 return; 4149 return;
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after
6325 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6324 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6326 } 6325 }
6327 6326
6328 void WebGLRenderingContextBase::restoreUnpackParameters() 6327 void WebGLRenderingContextBase::restoreUnpackParameters()
6329 { 6328 {
6330 if (m_unpackAlignment != 1) 6329 if (m_unpackAlignment != 1)
6331 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6330 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6332 } 6331 }
6333 6332
6334 } // namespace blink 6333 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698