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

Side by Side Diff: cc/output/shader.cc

Issue 1065463002: cc: Remove GLC macro (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « cc/output/gl_renderer.cc ('k') | cc/output/static_geometry_binding.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/output/shader.h" 5 #include "cc/output/shader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "cc/output/gl_renderer.h" // For the GLC() macro.
12 #include "gpu/command_buffer/client/gles2_interface.h" 11 #include "gpu/command_buffer/client/gles2_interface.h"
12 #include "ui/gfx/geometry/point.h"
13 #include "ui/gfx/geometry/size.h"
13 14
14 template <size_t size> 15 template <size_t size>
15 std::string StripLambda(const char(&shader)[size]) { 16 std::string StripLambda(const char(&shader)[size]) {
16 // Must contain at least "[]() {}" and trailing null (included in size). 17 // Must contain at least "[]() {}" and trailing null (included in size).
17 static_assert(size >= 8, 18 static_assert(size >= 8,
18 "String passed to StripLambda must be at least 8 characters"); 19 "String passed to StripLambda must be at least 8 characters");
19 DCHECK_EQ(strncmp("[]() {", shader, 6), 0); 20 DCHECK_EQ(strncmp("[]() {", shader, 6), 0);
20 DCHECK_EQ(shader[size - 2], '}'); 21 DCHECK_EQ(shader[size - 2], '}');
21 return std::string(shader + 6, shader + size - 2); 22 return std::string(shader + 6, shader + size - 2);
22 } 23 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 int highp_threshold_min, 90 int highp_threshold_min,
90 int x, 91 int x,
91 int y) { 92 int y) {
92 if (*highp_threshold_cache == 0) { 93 if (*highp_threshold_cache == 0) {
93 // Initialize range and precision with minimum spec values for when 94 // Initialize range and precision with minimum spec values for when
94 // GetShaderPrecisionFormat is a test stub. 95 // GetShaderPrecisionFormat is a test stub.
95 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat 96 // TODO(brianderson): Implement better stubs of GetShaderPrecisionFormat
96 // everywhere. 97 // everywhere.
97 GLint range[2] = {14, 14}; 98 GLint range[2] = {14, 14};
98 GLint precision = 10; 99 GLint precision = 10;
99 GLC(context, 100 context->GetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT,
100 context->GetShaderPrecisionFormat( 101 range, &precision);
101 GL_FRAGMENT_SHADER, GL_MEDIUM_FLOAT, range, &precision));
102 *highp_threshold_cache = 1 << precision; 102 *highp_threshold_cache = 1 << precision;
103 } 103 }
104 104
105 int highp_threshold = std::max(*highp_threshold_cache, highp_threshold_min); 105 int highp_threshold = std::max(*highp_threshold_cache, highp_threshold_min);
106 if (x > highp_threshold || y > highp_threshold) 106 if (x > highp_threshold || y > highp_threshold)
107 return TEX_COORD_PRECISION_HIGH; 107 return TEX_COORD_PRECISION_HIGH;
108 return TEX_COORD_PRECISION_MEDIUM; 108 return TEX_COORD_PRECISION_MEDIUM;
109 } 109 }
110 110
111 static std::string SetFragmentSamplerType(SamplerType requested_type, 111 static std::string SetFragmentSamplerType(SamplerType requested_type,
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2295 vec2 texCoord = 2295 vec2 texCoord =
2296 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; 2296 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy;
2297 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); 2297 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0);
2298 float picker = abs(coord.x - coord.y); // NOLINT 2298 float picker = abs(coord.x - coord.y); // NOLINT
2299 gl_FragColor = mix(color1, color2, picker) * alpha; 2299 gl_FragColor = mix(color1, color2, picker) * alpha;
2300 } 2300 }
2301 }); 2301 });
2302 } 2302 }
2303 2303
2304 } // namespace cc 2304 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | cc/output/static_geometry_binding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698