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

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

Issue 2728343002: Refactor CopyTexture method determination (Closed)
Patch Set: fix windows build Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 46620828f85d7d7c261a207988eae4ecfe5f2ea0..a47aa446d0697a85b4155464f49f966b9aa6e8e7 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2030,14 +2030,19 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
TextureRef* source_texture_ref,
TextureRef* dest_texture_ref);
bool CanUseCopyTextureCHROMIUMInternalFormat(GLenum dest_internal_format);
- CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats(
- const char* function_name,
- GLint source_level,
- GLenum source_internal_format,
- GLenum source_type,
- GLenum dest_target,
- GLint dest_level,
- GLenum dest_internal_format);
+ bool ValidateCopyTextureCHROMIUMInternalFormats(const char* function_name,
+ GLenum source_internal_format,
+ GLenum dest_internal_format);
+ CopyTextureMethod getCopyTextureCHROMIUMMethod(GLenum source_target,
+ GLint source_level,
+ GLenum source_internal_format,
+ GLenum source_type,
+ GLenum dest_target,
+ GLint dest_level,
+ GLenum dest_internal_format,
+ bool flip_y,
+ bool premultiply_alpha,
+ bool unpremultiply_alpha);
bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
TextureRef* source_texture_ref,
TextureRef* dest_texture_ref);
@@ -16309,13 +16314,9 @@ bool GLES2DecoderImpl::CanUseCopyTextureCHROMIUMInternalFormat(
}
}
-CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
+bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
const char* function_name,
- GLint source_level,
GLenum source_internal_format,
- GLenum source_type,
- GLenum dest_target,
- GLint dest_level,
GLenum dest_internal_format) {
bool valid_dest_format = false;
// TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats
@@ -16393,16 +16394,31 @@ CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
GLES2Util::GetStringEnum(source_internal_format);
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
msg.c_str());
- return NOT_COPYABLE;
+ return false;
}
if (!valid_dest_format) {
std::string msg = "invalid dest internal format " +
GLES2Util::GetStringEnum(dest_internal_format);
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
msg.c_str());
- return NOT_COPYABLE;
+ return false;
}
+ return true;
+}
+
+CopyTextureMethod GLES2DecoderImpl::getCopyTextureCHROMIUMMethod(
+ GLenum source_target,
+ GLint source_level,
+ GLenum source_internal_format,
+ GLenum source_type,
+ GLenum dest_target,
+ GLint dest_level,
+ GLenum dest_internal_format,
+ bool flip_y,
+ bool premultiply_alpha,
+ bool unpremultiply_alpha) {
+ bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
bool source_format_color_renderable =
Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false);
bool dest_format_color_renderable =
@@ -16429,8 +16445,10 @@ CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
// in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture
// either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in
// these cases.
- if (source_format_color_renderable && copy_tex_image_format_valid &&
- source_level == 0)
+ if (source_target == GL_TEXTURE_2D &&
+ (dest_target == GL_TEXTURE_2D || dest_target == GL_TEXTURE_CUBE_MAP) &&
+ source_format_color_renderable && copy_tex_image_format_valid &&
+ source_level == 0 && !flip_y && !premultiply_alpha_change)
return DIRECT_COPY;
if (dest_format_color_renderable && dest_level == 0 &&
dest_target != GL_TEXTURE_CUBE_MAP)
@@ -16534,12 +16552,8 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
return;
}
- CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats(
- kFunctionName, source_level, source_internal_format, source_type,
- dest_binding_target, dest_level, internal_format);
- // INVALID_OPERATION is already generated by
- // ValidateCopyTextureCHROMIUMInternalFormats.
- if (method == NOT_COPYABLE) {
+ if (!ValidateCopyTextureCHROMIUMInternalFormats(
+ kFunctionName, source_internal_format, internal_format)) {
return;
}
@@ -16669,6 +16683,11 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
}
}
+ CopyTextureMethod method = getCopyTextureCHROMIUMMethod(
+ source_target, source_level, source_internal_format, source_type,
+ dest_binding_target, dest_level, internal_format,
+ unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
+ unpack_unmultiply_alpha == GL_TRUE);
copy_texture_CHROMIUM_->DoCopyTexture(
this, source_target, source_texture->service_id(), source_level,
source_internal_format, dest_target, dest_texture->service_id(),
@@ -16786,27 +16805,11 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
return;
}
- CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats(
- kFunctionName, source_level, source_internal_format, source_type,
- dest_binding_target, dest_level, dest_internal_format);
- // INVALID_OPERATION is already generated by
- // ValidateCopyTextureCHROMIUMInternalFormats.
- if (method == NOT_COPYABLE) {
+ if (!ValidateCopyTextureCHROMIUMInternalFormats(
+ kFunctionName, source_internal_format, dest_internal_format)) {
return;
}
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
- // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver,
- // although opposite in Android.
- // TODO(dshwang): After Mesa fixes this issue, remove this hack.
- // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198.
- if (Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format,
- dest_texture->IsImmutable()) &&
- method == DIRECT_COPY) {
- method = DIRECT_DRAW;
- }
-#endif
-
if (feature_info_->feature_flags().desktop_srgb_support) {
bool enable_framebuffer_srgb =
GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) ==
@@ -16892,6 +16895,24 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
return;
}
}
+
+ CopyTextureMethod method = getCopyTextureCHROMIUMMethod(
+ source_target, source_level, source_internal_format, source_type,
+ dest_binding_target, dest_level, dest_internal_format,
+ unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
+ unpack_unmultiply_alpha == GL_TRUE);
+#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+ // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver,
+ // although opposite in Android.
+ // TODO(dshwang): After Mesa fixes this issue, remove this hack.
+ // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198.
+ if (Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format,
+ dest_texture->IsImmutable()) &&
+ method == DIRECT_COPY) {
+ method = DIRECT_DRAW;
+ }
+#endif
+
copy_texture_CHROMIUM_->DoCopySubTexture(
this, source_target, source_texture->service_id(), source_level,
source_internal_format, dest_target, dest_texture->service_id(),
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698