OLD | NEW |
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/program_binding.h" | 5 #include "cc/output/program_binding.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "cc/output/geometry_binding.h" | 8 #include "cc/output/geometry_binding.h" |
9 #include "gpu/GLES2/gl2extchromium.h" | 9 #include "gpu/GLES2/gl2extchromium.h" |
10 #include "gpu/command_buffer/client/gles2_interface.h" | 10 #include "gpu/command_buffer/client/gles2_interface.h" |
| 11 #include "ui/gfx/color_transform.h" |
11 | 12 |
12 using gpu::gles2::GLES2Interface; | 13 using gpu::gles2::GLES2Interface; |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 | 16 |
16 ProgramKey::ProgramKey() = default; | 17 ProgramKey::ProgramKey() = default; |
17 ProgramKey::ProgramKey(const ProgramKey& other) = default; | 18 ProgramKey::ProgramKey(const ProgramKey& other) = default; |
18 ProgramKey::~ProgramKey() = default; | 19 ProgramKey::~ProgramKey() = default; |
19 | 20 |
20 bool ProgramKey::operator==(const ProgramKey& other) const { | 21 bool ProgramKey::operator==(const ProgramKey& other) const { |
21 return type_ == other.type_ && precision_ == other.precision_ && | 22 return type_ == other.type_ && precision_ == other.precision_ && |
22 sampler_ == other.sampler_ && blend_mode_ == other.blend_mode_ && | 23 sampler_ == other.sampler_ && blend_mode_ == other.blend_mode_ && |
23 aa_mode_ == other.aa_mode_ && swizzle_mode_ == other.swizzle_mode_ && | 24 aa_mode_ == other.aa_mode_ && swizzle_mode_ == other.swizzle_mode_ && |
24 is_opaque_ == other.is_opaque_ && | 25 is_opaque_ == other.is_opaque_ && |
25 premultiplied_alpha_ == other.premultiplied_alpha_ && | 26 premultiplied_alpha_ == other.premultiplied_alpha_ && |
26 has_background_color_ == other.has_background_color_ && | 27 has_background_color_ == other.has_background_color_ && |
27 mask_mode_ == other.mask_mode_ && | 28 mask_mode_ == other.mask_mode_ && |
28 mask_for_background_ == other.mask_for_background_ && | 29 mask_for_background_ == other.mask_for_background_ && |
29 has_color_matrix_ == other.has_color_matrix_ && | 30 has_color_matrix_ == other.has_color_matrix_ && |
30 yuv_alpha_texture_mode_ == other.yuv_alpha_texture_mode_ && | 31 yuv_alpha_texture_mode_ == other.yuv_alpha_texture_mode_ && |
31 uv_texture_mode_ == other.uv_texture_mode_ && | 32 uv_texture_mode_ == other.uv_texture_mode_ && |
32 color_conversion_mode_ == other.color_conversion_mode_; | 33 color_conversion_mode_ == other.color_conversion_mode_ && |
| 34 color_transform_ == other.color_transform_; |
33 } | 35 } |
34 | 36 |
35 bool ProgramKey::operator!=(const ProgramKey& other) const { | 37 bool ProgramKey::operator!=(const ProgramKey& other) const { |
36 return !(*this == other); | 38 return !(*this == other); |
37 } | 39 } |
38 | 40 |
39 // static | 41 // static |
40 ProgramKey ProgramKey::DebugBorder() { | 42 ProgramKey ProgramKey::DebugBorder() { |
41 ProgramKey result; | 43 ProgramKey result; |
42 result.type_ = PROGRAM_TYPE_DEBUG_BORDER; | 44 result.type_ = PROGRAM_TYPE_DEBUG_BORDER; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 result.sampler_ = sampler; | 123 result.sampler_ = sampler; |
122 result.yuv_alpha_texture_mode_ = yuv_alpha_texture_mode; | 124 result.yuv_alpha_texture_mode_ = yuv_alpha_texture_mode; |
123 DCHECK(yuv_alpha_texture_mode == YUV_NO_ALPHA_TEXTURE || | 125 DCHECK(yuv_alpha_texture_mode == YUV_NO_ALPHA_TEXTURE || |
124 yuv_alpha_texture_mode == YUV_HAS_ALPHA_TEXTURE); | 126 yuv_alpha_texture_mode == YUV_HAS_ALPHA_TEXTURE); |
125 result.uv_texture_mode_ = uv_texture_mode; | 127 result.uv_texture_mode_ = uv_texture_mode; |
126 DCHECK(uv_texture_mode == UV_TEXTURE_MODE_UV || | 128 DCHECK(uv_texture_mode == UV_TEXTURE_MODE_UV || |
127 uv_texture_mode == UV_TEXTURE_MODE_U_V); | 129 uv_texture_mode == UV_TEXTURE_MODE_U_V); |
128 return result; | 130 return result; |
129 } | 131 } |
130 | 132 |
| 133 void ProgramKey::SetColorTransform(const gfx::ColorTransform* transform) { |
| 134 color_transform_ = nullptr; |
| 135 if (transform->IsIdentity()) { |
| 136 color_conversion_mode_ = COLOR_CONVERSION_MODE_NONE; |
| 137 } else if (transform->CanGetShaderSource()) { |
| 138 color_conversion_mode_ = COLOR_CONVERSION_MODE_SHADER; |
| 139 color_transform_ = transform; |
| 140 } else { |
| 141 color_conversion_mode_ = COLOR_CONVERSION_MODE_LUT; |
| 142 } |
| 143 } |
| 144 |
131 ProgramBindingBase::ProgramBindingBase() | 145 ProgramBindingBase::ProgramBindingBase() |
132 : program_(0), | 146 : program_(0), |
133 vertex_shader_id_(0), | 147 vertex_shader_id_(0), |
134 fragment_shader_id_(0), | 148 fragment_shader_id_(0), |
135 initialized_(false) {} | 149 initialized_(false) {} |
136 | 150 |
137 ProgramBindingBase::~ProgramBindingBase() { | 151 ProgramBindingBase::~ProgramBindingBase() { |
138 // If you hit these asserts, you initialized but forgot to call Cleanup(). | 152 // If you hit these asserts, you initialized but forgot to call Cleanup(). |
139 DCHECK(!program_); | 153 DCHECK(!program_); |
140 DCHECK(!vertex_shader_id_); | 154 DCHECK(!vertex_shader_id_); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 context->DeleteShader(fragment_shader_id_); | 266 context->DeleteShader(fragment_shader_id_); |
253 fragment_shader_id_ = 0; | 267 fragment_shader_id_ = 0; |
254 } | 268 } |
255 } | 269 } |
256 | 270 |
257 bool ProgramBindingBase::IsContextLost(GLES2Interface* context) { | 271 bool ProgramBindingBase::IsContextLost(GLES2Interface* context) { |
258 return context->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 272 return context->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
259 } | 273 } |
260 | 274 |
261 } // namespace cc | 275 } // namespace cc |
OLD | NEW |