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

Unified Diff: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc

Issue 1275773003: gpu: support GL_TEXTURE_CUBE_MAP destination target to Copy(Sub)TextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address piman's comments Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
index 846ac0d6a12b9be9218a3d26a2a866fc87c67292..f32ea37f714ade79ffb66bba442db71f721c1f7e 100644
--- a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
+++ b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/basictypes.h"
+#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
@@ -200,15 +201,18 @@ void DeleteShader(GLuint shader) {
bool BindFramebufferTexture2D(GLenum target,
GLuint texture_id,
GLuint framebuffer) {
- DCHECK(target == GL_TEXTURE_2D || target == GL_TEXTURE_RECTANGLE_ARB);
+ GLenum binding_target = gpu::gles2::GLES2Util::GLFaceToTarget(target);
+ DCHECK(binding_target == GL_TEXTURE_2D ||
+ binding_target == GL_TEXTURE_RECTANGLE_ARB ||
+ binding_target == GL_TEXTURE_CUBE_MAP);
glActiveTexture(GL_TEXTURE0);
- glBindTexture(target, texture_id);
+ glBindTexture(binding_target, texture_id);
// NVidia drivers require texture settings to be a certain way
// or they won't report FRAMEBUFFER_COMPLETE.
- glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
texture_id, 0);
@@ -226,6 +230,7 @@ bool BindFramebufferTexture2D(GLenum target,
void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder,
GLenum source_target,
GLuint source_id,
+ GLenum dest_target,
GLuint dest_id,
GLenum dest_internal_format,
GLsizei width,
@@ -234,12 +239,13 @@ void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder,
DCHECK(source_target == GL_TEXTURE_2D ||
source_target == GL_TEXTURE_RECTANGLE_ARB);
if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) {
- glBindTexture(GL_TEXTURE_2D, dest_id);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glCopyTexImage2D(GL_TEXTURE_2D, 0 /* level */, dest_internal_format,
+ GLenum binding_target = gpu::gles2::GLES2Util::GLFaceToTarget(dest_target);
+ glBindTexture(binding_target, dest_id);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glCopyTexImage2D(dest_target, 0 /* level */, dest_internal_format,
0 /* x */, 0 /* y */, width, height, 0 /* border */);
}
@@ -253,6 +259,7 @@ void DoCopyTexImage2D(const gpu::gles2::GLES2Decoder* decoder,
void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder,
GLenum source_target,
GLuint source_id,
+ GLenum dest_target,
GLuint dest_id,
GLint xoffset,
GLint yoffset,
@@ -264,13 +271,14 @@ void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder,
DCHECK(source_target == GL_TEXTURE_2D ||
source_target == GL_TEXTURE_RECTANGLE_ARB);
if (BindFramebufferTexture2D(source_target, source_id, framebuffer)) {
- glBindTexture(GL_TEXTURE_2D, dest_id);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0 /* level */, xoffset, yoffset,
- source_x, source_y, source_width, source_height);
+ GLenum binding_target = gpu::gles2::GLES2Util::GLFaceToTarget(dest_target);
+ glBindTexture(binding_target, dest_id);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glCopyTexSubImage2D(dest_target, 0 /* level */, xoffset, yoffset, source_x,
+ source_y, source_width, source_height);
}
decoder->RestoreTextureState(source_id);
@@ -349,6 +357,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
GLenum source_target,
GLuint source_id,
GLenum source_internal_format,
+ GLenum dest_target,
GLuint dest_id,
GLenum dest_internal_format,
GLsizei width,
@@ -369,20 +378,14 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
// so restrict this to GL_TEXTURE_2D.
if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
source_format_contain_superset_of_dest_format) {
- DoCopyTexImage2D(decoder,
- source_target,
- source_id,
- dest_id,
- dest_internal_format,
- width,
- height,
- framebuffer_);
+ DoCopyTexImage2D(decoder, source_target, source_id, dest_target, dest_id,
+ dest_internal_format, width, height, framebuffer_);
return;
}
// Use kIdentityMatrix if no transform passed in.
- DoCopyTextureWithTransform(decoder, source_target, source_id, dest_id, width,
- height, flip_y, premultiply_alpha,
+ DoCopyTextureWithTransform(decoder, source_target, source_id, dest_target,
+ dest_id, width, height, flip_y, premultiply_alpha,
unpremultiply_alpha, kIdentityMatrix);
}
@@ -391,6 +394,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
GLenum source_target,
GLuint source_id,
GLenum source_internal_format,
+ GLenum dest_target,
GLuint dest_id,
GLenum dest_internal_format,
GLint xoffset,
@@ -419,21 +423,22 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
// so restrict this to GL_TEXTURE_2D.
if (source_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
source_format_contain_superset_of_dest_format) {
- DoCopyTexSubImage2D(decoder, source_target, source_id, dest_id, xoffset,
- yoffset, x, y, width, height, framebuffer_);
+ DoCopyTexSubImage2D(decoder, source_target, source_id, dest_target, dest_id,
+ xoffset, yoffset, x, y, width, height, framebuffer_);
return;
}
- DoCopyTextureInternal(decoder, source_target, source_id, dest_id, xoffset,
- yoffset, x, y, width, height, dest_width, dest_height,
- source_width, source_height, flip_y, premultiply_alpha,
- unpremultiply_alpha, kIdentityMatrix);
+ DoCopyTextureInternal(
+ decoder, source_target, source_id, dest_target, dest_id, xoffset, yoffset,
+ x, y, width, height, dest_width, dest_height, source_width, source_height,
+ flip_y, premultiply_alpha, unpremultiply_alpha, kIdentityMatrix);
}
void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
const gles2::GLES2Decoder* decoder,
GLenum source_target,
GLuint source_id,
+ GLenum dest_target,
GLuint dest_id,
GLsizei width,
GLsizei height,
@@ -443,16 +448,17 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTextureWithTransform(
const GLfloat transform_matrix[16]) {
GLsizei dest_width = width;
GLsizei dest_height = height;
- DoCopyTextureInternal(decoder, source_target, source_id, dest_id, 0, 0, 0, 0,
- width, height, dest_width, dest_height, width, height,
- flip_y, premultiply_alpha, unpremultiply_alpha,
- transform_matrix);
+ DoCopyTextureInternal(decoder, source_target, source_id, dest_target, dest_id,
+ 0, 0, 0, 0, width, height, dest_width, dest_height,
+ width, height, flip_y, premultiply_alpha,
+ unpremultiply_alpha, transform_matrix);
}
void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal(
const gles2::GLES2Decoder* decoder,
GLenum source_target,
GLuint source_id,
+ GLenum dest_target,
GLuint dest_id,
GLint xoffset,
GLint yoffset,
@@ -542,7 +548,7 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTextureInternal(
else
glUniform2f(info->half_size_handle, 0.5f, 0.5f);
- if (BindFramebufferTexture2D(GL_TEXTURE_2D, dest_id, framebuffer_)) {
+ if (BindFramebufferTexture2D(dest_target, dest_id, framebuffer_)) {
#ifndef NDEBUG
// glValidateProgram of MACOSX validates FBO unlike other platforms, so
// glValidateProgram must be called after FBO binding. crbug.com/463439

Powered by Google App Engine
This is Rietveld 408576698