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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc

Issue 2030483002: Allow premultiply_alpha + unpremultiply_alpha in CopyTextureCHROMIUMResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 5 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 19 matching lines...) Expand all
30 FRAGMENT_SHADER_COPY_TEXTURE_UNPREMULTIPLY_ALPHA_RECTANGLE_ARB, 30 FRAGMENT_SHADER_COPY_TEXTURE_UNPREMULTIPLY_ALPHA_RECTANGLE_ARB,
31 FRAGMENT_SHADER_COPY_TEXTURE_UNPREMULTIPLY_ALPHA_EXTERNAL_OES, 31 FRAGMENT_SHADER_COPY_TEXTURE_UNPREMULTIPLY_ALPHA_EXTERNAL_OES,
32 NUM_FRAGMENT_SHADERS, 32 NUM_FRAGMENT_SHADERS,
33 }; 33 };
34 34
35 // Returns the correct fragment shader id to evaluate the copy operation for 35 // Returns the correct fragment shader id to evaluate the copy operation for
36 // the premultiply alpha pixel store settings and target. 36 // the premultiply alpha pixel store settings and target.
37 FragmentShaderId GetFragmentShaderId(bool premultiply_alpha, 37 FragmentShaderId GetFragmentShaderId(bool premultiply_alpha,
38 bool unpremultiply_alpha, 38 bool unpremultiply_alpha,
39 GLenum target) { 39 GLenum target) {
40 // Only one alpha mode at a time makes sense.
41 DCHECK(!premultiply_alpha || !unpremultiply_alpha);
42
43 enum { 40 enum {
44 SAMPLER_2D, 41 SAMPLER_2D,
45 SAMPLER_RECTANGLE_ARB, 42 SAMPLER_RECTANGLE_ARB,
46 SAMPLER_EXTERNAL_OES, 43 SAMPLER_EXTERNAL_OES,
47 NUM_SAMPLERS 44 NUM_SAMPLERS
48 }; 45 };
49 46
50 // bit 0: premultiply alpha 47 // bit 0: premultiply alpha
51 // bit 1: unpremultiply alpha 48 // bit 1: unpremultiply alpha
52 static FragmentShaderId shader_ids[][NUM_SAMPLERS] = { 49 static FragmentShaderId shader_ids[][NUM_SAMPLERS] = {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 u_vertex_dest_add;\n\ 126 u_vertex_dest_add;\n\
130 v_uv = a_position.xy * u_vertex_source_mult + u_vertex_source_add;\n\ 127 v_uv = a_position.xy * u_vertex_source_mult + u_vertex_source_add;\n\
131 }\n"); 128 }\n");
132 129
133 return source; 130 return source;
134 } 131 }
135 132
136 std::string GetFragmentShaderSource(bool premultiply_alpha, 133 std::string GetFragmentShaderSource(bool premultiply_alpha,
137 bool unpremultiply_alpha, 134 bool unpremultiply_alpha,
138 GLenum target) { 135 GLenum target) {
139 // Only one alpha mode at a time makes sense.
140 DCHECK(!premultiply_alpha || !unpremultiply_alpha);
141
142 std::string source; 136 std::string source;
143 137
144 // Preamble for core and compatibility mode. 138 // Preamble for core and compatibility mode.
145 if (gl::GetGLImplementation() == gl::kGLImplementationDesktopGLCoreProfile) { 139 if (gl::GetGLImplementation() == gl::kGLImplementationDesktopGLCoreProfile) {
146 source += std::string("\ 140 source += std::string("\
147 #version 150\n\ 141 #version 150\n\
148 out vec4 frag_color;\n\ 142 out vec4 frag_color;\n\
149 #define VARYING in\n\ 143 #define VARYING in\n\
150 #define FRAGCOLOR frag_color\n\ 144 #define FRAGCOLOR frag_color\n\
151 #define TextureLookup texture\n"); 145 #define TextureLookup texture\n");
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 decoder->RestoreTextureState(dest_id); 749 decoder->RestoreTextureState(dest_id);
756 decoder->RestoreTextureUnitBindings(0); 750 decoder->RestoreTextureUnitBindings(0);
757 decoder->RestoreActiveTexture(); 751 decoder->RestoreActiveTexture();
758 decoder->RestoreProgramBindings(); 752 decoder->RestoreProgramBindings();
759 decoder->RestoreBufferBindings(); 753 decoder->RestoreBufferBindings();
760 decoder->RestoreFramebufferBindings(); 754 decoder->RestoreFramebufferBindings();
761 decoder->RestoreGlobalState(); 755 decoder->RestoreGlobalState();
762 } 756 }
763 757
764 } // namespace gpu 758 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698