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

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

Issue 2460973002: gpu, cmaa: reuse CopyTextureCHROMIUMResourceManager (Closed)
Patch Set: reuse CopyTextureCHROMIUMResourceManager Created 4 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 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 8b53d0f4c402449b60fab2c23a0e1b514bb7307d..a3ada9c1d77c399a1bd9cc69007a2b8424e1a94f 100644
--- a/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
+++ b/gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc
@@ -319,6 +319,36 @@ void DoCopyTexSubImage2D(const gpu::gles2::GLES2Decoder* decoder,
decoder->RestoreFramebufferBindings();
}
+GLenum UnsizedFormatFrom(GLenum internal_format) {
+ switch (internal_format) {
+ case GL_RGB:
+ case GL_RGB8:
+ return GL_RGB;
+ case GL_RGBA:
+ case GL_RGBA8:
+ return GL_RGBA;
+ case GL_BGRA_EXT:
+ case GL_BGRA8_EXT:
+ return GL_BGRA_EXT;
+ default:
+ NOTREACHED();
piman 2016/11/01 19:04:59 I think this needs to be expanded to more formats.
dshwang 2016/11/01 19:30:05 exactly, this DCHECK causes crash. Done.
dshwang 2016/11/01 19:35:17 I gave up this non-trivial change which cause lots
+ return GL_RGBA;
+ }
+}
+
+// GL_INVALID_OPERATION is generated if the currently bound framebuffer's
+// format does not contain a superset of the components required by the base
+// format of internalformat.
+// https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
+bool SourceFormatContainSupersetOfDestFormat(GLenum source_internal_format,
+ GLenum dest_internal_format) {
+ return (UnsizedFormatFrom(source_internal_format) ==
+ UnsizedFormatFrom(dest_internal_format) &&
+ UnsizedFormatFrom(source_internal_format) != GL_BGRA_EXT) ||
+ (UnsizedFormatFrom(source_internal_format) == GL_RGBA &&
+ UnsizedFormatFrom(dest_internal_format) == GL_RGB);
+}
+
} // namespace
namespace gpu {
@@ -421,14 +451,9 @@ void CopyTextureCHROMIUMResourceManager::DoCopyTexture(
bool premultiply_alpha,
bool unpremultiply_alpha) {
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
- // GL_INVALID_OPERATION is generated if the currently bound framebuffer's
- // format does not contain a superset of the components required by the base
- // format of internalformat.
- // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
bool source_format_contain_superset_of_dest_format =
- (source_internal_format == dest_internal_format &&
- source_internal_format != GL_BGRA_EXT) ||
- (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB);
+ SourceFormatContainSupersetOfDestFormat(source_internal_format,
+ dest_internal_format);
// GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
// so restrict this to GL_TEXTURE_2D.
if (source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D &&
@@ -473,19 +498,22 @@ void CopyTextureCHROMIUMResourceManager::DoCopySubTexture(
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha) {
+ bool use_gl_copy_tex_sub_image_2d = 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
+ use_gl_copy_tex_sub_image_2d = false;
+#endif
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
- // GL_INVALID_OPERATION is generated if the currently bound framebuffer's
- // format does not contain a superset of the components required by the base
- // format of internalformat.
- // https://www.khronos.org/opengles/sdk/docs/man/xhtml/glCopyTexImage2D.xml
bool source_format_contain_superset_of_dest_format =
- (source_internal_format == dest_internal_format &&
- source_internal_format != GL_BGRA_EXT) ||
- (source_internal_format == GL_RGBA && dest_internal_format == GL_RGB);
+ SourceFormatContainSupersetOfDestFormat(source_internal_format,
+ dest_internal_format);
// GL_TEXTURE_RECTANGLE_ARB on FBO is supported by OpenGL, not GLES2,
// so restrict this to GL_TEXTURE_2D.
- if (source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D &&
- !flip_y && !premultiply_alpha_change &&
+ if (use_gl_copy_tex_sub_image_2d && source_target == GL_TEXTURE_2D &&
+ dest_target == GL_TEXTURE_2D && !flip_y && !premultiply_alpha_change &&
source_format_contain_superset_of_dest_format) {
DoCopyTexSubImage2D(decoder, source_target, source_id, dest_target, dest_id,
xoffset, yoffset, x, y, width, height, framebuffer_);

Powered by Google App Engine
This is Rietveld 408576698