| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 GLRendererPixelTest::SetUp(); | 125 GLRendererPixelTest::SetUp(); |
| 126 ASSERT_FALSE(renderer()->IsContextLost()); | 126 ASSERT_FALSE(renderer()->IsContextLost()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void TearDown() override { | 129 void TearDown() override { |
| 130 GLRendererPixelTest::TearDown(); | 130 GLRendererPixelTest::TearDown(); |
| 131 ASSERT_FALSE(renderer()->IsContextLost()); | 131 ASSERT_FALSE(renderer()->IsContextLost()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void TestBasicShaders() { | 134 void TestBasicShaders() { |
| 135 EXPECT_PROGRAM_VALID(renderer()->GetDebugBorderProgram()); | 135 EXPECT_PROGRAM_VALID(renderer()->GetProgram(ProgramKey::DebugBorder())); |
| 136 EXPECT_PROGRAM_VALID(renderer()->GetSolidColorProgram()); | 136 EXPECT_PROGRAM_VALID(renderer()->GetProgram(ProgramKey::SolidColor(NO_AA))); |
| 137 EXPECT_PROGRAM_VALID(renderer()->GetSolidColorProgramAA()); | 137 EXPECT_PROGRAM_VALID( |
| 138 renderer()->GetProgram(ProgramKey::SolidColor(USE_AA))); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void TestShadersWithPrecision(TexCoordPrecision precision) { | 141 void TestShadersWithPrecision(TexCoordPrecision precision) { |
| 141 // This program uses external textures and sampler, so it won't compile | 142 // This program uses external textures and sampler, so it won't compile |
| 142 // everywhere. | 143 // everywhere. |
| 143 if (context_provider()->ContextCapabilities().egl_image_external) | 144 if (context_provider()->ContextCapabilities().egl_image_external) |
| 144 EXPECT_PROGRAM_VALID(renderer()->GetVideoStreamTextureProgram(precision)); | 145 EXPECT_PROGRAM_VALID( |
| 146 renderer()->GetProgram(ProgramKey::VideoStream(precision))); |
| 145 } | 147 } |
| 146 | 148 |
| 147 void TestShadersWithPrecisionAndBlend(TexCoordPrecision precision, | 149 void TestShadersWithPrecisionAndBlend(TexCoordPrecision precision, |
| 148 BlendMode blend_mode) { | 150 BlendMode blend_mode) { |
| 149 EXPECT_PROGRAM_VALID( | 151 EXPECT_PROGRAM_VALID(renderer()->GetProgram(ProgramKey::RenderPass( |
| 150 renderer()->GetRenderPassProgram(precision, blend_mode)); | 152 precision, SAMPLER_TYPE_2D, blend_mode, NO_AA, NO_MASK, false, false))); |
| 151 EXPECT_PROGRAM_VALID( | 153 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 152 renderer()->GetRenderPassProgramAA(precision, blend_mode)); | 154 ProgramKey::RenderPass(precision, SAMPLER_TYPE_2D, blend_mode, USE_AA, |
| 155 NO_MASK, false, false))); |
| 153 } | 156 } |
| 154 | 157 |
| 155 void TestShadersWithPrecisionAndSampler(TexCoordPrecision precision, | 158 void TestShadersWithPrecisionAndSampler(TexCoordPrecision precision, |
| 156 SamplerType sampler) { | 159 SamplerType sampler) { |
| 157 if (!context_provider()->ContextCapabilities().egl_image_external && | 160 if (!context_provider()->ContextCapabilities().egl_image_external && |
| 158 sampler == SAMPLER_TYPE_EXTERNAL_OES) { | 161 sampler == SAMPLER_TYPE_EXTERNAL_OES) { |
| 159 // This will likely be hit in tests due to usage of osmesa. | 162 // This will likely be hit in tests due to usage of osmesa. |
| 160 return; | 163 return; |
| 161 } | 164 } |
| 162 | 165 |
| 163 EXPECT_PROGRAM_VALID(renderer()->GetTextureProgram(precision, sampler)); | 166 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 164 EXPECT_PROGRAM_VALID( | 167 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, false))); |
| 165 renderer()->GetNonPremultipliedTextureProgram(precision, sampler)); | 168 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 166 EXPECT_PROGRAM_VALID( | 169 ProgramKey::Texture(precision, sampler, PREMULTIPLIED_ALPHA, true))); |
| 167 renderer()->GetTextureBackgroundProgram(precision, sampler)); | 170 EXPECT_PROGRAM_VALID(renderer()->GetProgram(ProgramKey::Texture( |
| 168 EXPECT_PROGRAM_VALID( | 171 precision, sampler, NON_PREMULTIPLIED_ALPHA, false))); |
| 169 renderer()->GetNonPremultipliedTextureBackgroundProgram(precision, | 172 EXPECT_PROGRAM_VALID(renderer()->GetProgram(ProgramKey::Texture( |
| 170 sampler)); | 173 precision, sampler, NON_PREMULTIPLIED_ALPHA, true))); |
| 171 | 174 |
| 172 EXPECT_PROGRAM_VALID(renderer()->GetTileProgram(precision, sampler)); | 175 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 173 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramOpaque(precision, sampler)); | 176 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, false))); |
| 174 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramAA(precision, sampler)); | 177 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 175 EXPECT_PROGRAM_VALID(renderer()->GetTileProgramSwizzle(precision, sampler)); | 178 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, false))); |
| 176 EXPECT_PROGRAM_VALID( | 179 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 177 renderer()->GetTileProgramSwizzleOpaque(precision, sampler)); | 180 ProgramKey::Tile(precision, sampler, USE_AA, NO_SWIZZLE, false))); |
| 178 EXPECT_PROGRAM_VALID( | 181 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 179 renderer()->GetTileProgramSwizzleAA(precision, sampler)); | 182 ProgramKey::Tile(precision, sampler, USE_AA, DO_SWIZZLE, false))); |
| 183 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 184 ProgramKey::Tile(precision, sampler, NO_AA, NO_SWIZZLE, true))); |
| 185 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 186 ProgramKey::Tile(precision, sampler, NO_AA, DO_SWIZZLE, true))); |
| 187 |
| 180 for (int j = 0; j < 2; j++) { | 188 for (int j = 0; j < 2; j++) { |
| 181 for (int k = 0; k < 2; k++) { | 189 for (int k = 0; k < 2; k++) { |
| 182 for (int l = 0; l < 2; l++) { | 190 for (int l = 0; l < 2; l++) { |
| 183 EXPECT_PROGRAM_VALID( | 191 EXPECT_PROGRAM_VALID( |
| 184 renderer()->GetVideoYUVProgram(precision, sampler, j, k, l)); | 192 renderer()->GetVideoYUVProgram(precision, sampler, j, k, l)); |
| 185 } | 193 } |
| 186 } | 194 } |
| 187 } | 195 } |
| 188 } | 196 } |
| 189 | 197 |
| 190 void TestShadersWithMasks(TexCoordPrecision precision, | 198 void TestShadersWithMasks(TexCoordPrecision precision, |
| 191 SamplerType sampler, | 199 SamplerType sampler, |
| 192 BlendMode blend_mode, | 200 BlendMode blend_mode, |
| 193 bool mask_for_background) { | 201 bool mask_for_background) { |
| 194 if (!context_provider()->ContextCapabilities().egl_image_external && | 202 if (!context_provider()->ContextCapabilities().egl_image_external && |
| 195 sampler == SAMPLER_TYPE_EXTERNAL_OES) { | 203 sampler == SAMPLER_TYPE_EXTERNAL_OES) { |
| 196 // This will likely be hit in tests due to usage of osmesa. | 204 // This will likely be hit in tests due to usage of osmesa. |
| 197 return; | 205 return; |
| 198 } | 206 } |
| 199 | 207 |
| 200 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskProgram( | 208 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 201 precision, sampler, blend_mode, mask_for_background)); | 209 ProgramKey::RenderPass(precision, sampler, blend_mode, NO_AA, HAS_MASK, |
| 202 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskProgramAA( | 210 mask_for_background, false))); |
| 203 precision, sampler, blend_mode, mask_for_background)); | 211 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 204 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgramAA( | 212 ProgramKey::RenderPass(precision, sampler, blend_mode, NO_AA, HAS_MASK, |
| 205 precision, sampler, blend_mode, mask_for_background)); | 213 mask_for_background, true))); |
| 206 EXPECT_PROGRAM_VALID(renderer()->GetRenderPassMaskColorMatrixProgram( | 214 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 207 precision, sampler, blend_mode, mask_for_background)); | 215 ProgramKey::RenderPass(precision, sampler, blend_mode, USE_AA, HAS_MASK, |
| 216 mask_for_background, false))); |
| 217 EXPECT_PROGRAM_VALID(renderer()->GetProgram( |
| 218 ProgramKey::RenderPass(precision, sampler, blend_mode, USE_AA, HAS_MASK, |
| 219 mask_for_background, true))); |
| 208 } | 220 } |
| 209 }; | 221 }; |
| 210 | 222 |
| 211 namespace { | 223 namespace { |
| 212 | 224 |
| 213 #if !defined(OS_ANDROID) && !defined(OS_WIN) | 225 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 214 static const TexCoordPrecision kPrecisionList[] = {TEX_COORD_PRECISION_MEDIUM, | 226 static const TexCoordPrecision kPrecisionList[] = {TEX_COORD_PRECISION_MEDIUM, |
| 215 TEX_COORD_PRECISION_HIGH}; | 227 TEX_COORD_PRECISION_HIGH}; |
| 216 | 228 |
| 217 static const BlendMode kBlendModeList[LAST_BLEND_MODE + 1] = { | 229 static const BlendMode kBlendModeList[LAST_BLEND_MODE + 1] = { |
| (...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 renderer_->SetVisible(true); | 1973 renderer_->SetVisible(true); |
| 1962 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1974 Mock::VerifyAndClearExpectations(context_support_ptr_); |
| 1963 | 1975 |
| 1964 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); | 1976 EXPECT_CALL(*context_support_ptr_, SetAggressivelyFreeResources(true)); |
| 1965 renderer_->SetVisible(false); | 1977 renderer_->SetVisible(false); |
| 1966 Mock::VerifyAndClearExpectations(context_support_ptr_); | 1978 Mock::VerifyAndClearExpectations(context_support_ptr_); |
| 1967 } | 1979 } |
| 1968 | 1980 |
| 1969 } // namespace | 1981 } // namespace |
| 1970 } // namespace cc | 1982 } // namespace cc |
| OLD | NEW |