mirror of https://github.com/aseprite/aseprite.git
				
				
				
			Use make_shader() helper function to create ColorSelector shaders
This commit is contained in:
		
							parent
							
								
									7905acf38a
								
							
						
					
					
						commit
						a0e469624a
					
				|  | @ -655,35 +655,22 @@ bool ColorSelector::buildEffects() | |||
| 
 | ||||
|   if (!m_mainEffect) { | ||||
|     if (const char* code = getMainAreaShader()) | ||||
|       m_mainEffect = buildEffect(code); | ||||
|       m_mainEffect = make_shader(code); | ||||
|   } | ||||
| 
 | ||||
|   if (!m_bottomEffect) { | ||||
|     if (const char* code = getBottomBarShader()) | ||||
|       m_bottomEffect = buildEffect(code); | ||||
|       m_bottomEffect = make_shader(code); | ||||
|   } | ||||
| 
 | ||||
|   if (!m_alphaEffect) { | ||||
|     if (const char* code = getAlphaBarShader()) | ||||
|       m_alphaEffect = buildEffect(code); | ||||
|       m_alphaEffect = make_shader(code); | ||||
|   } | ||||
| 
 | ||||
|   return (m_mainEffect && m_bottomEffect && m_alphaEffect); | ||||
| } | ||||
| 
 | ||||
| sk_sp<SkRuntimeEffect> ColorSelector::buildEffect(const char* code) | ||||
| { | ||||
|   auto result = SkRuntimeEffect::MakeForShader(SkString(code)); | ||||
|   if (!result.errorText.isEmpty()) { | ||||
|     LOG(ERROR, "Shader error: %s\n", result.errorText.c_str()); | ||||
|     std::printf("Shader error: %s\n", result.errorText.c_str()); | ||||
|     return nullptr; | ||||
|   } | ||||
|   else { | ||||
|     return result.effect; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void ColorSelector::resetBottomEffect() | ||||
| { | ||||
|   m_bottomEffect.reset(); | ||||
|  |  | |||
|  | @ -121,7 +121,6 @@ namespace app { | |||
| #if SK_ENABLE_SKSL | ||||
|     static const char* getAlphaBarShader(); | ||||
|     bool buildEffects(); | ||||
|     sk_sp<SkRuntimeEffect> buildEffect(const char* code); | ||||
| #endif | ||||
| 
 | ||||
|     // Internal flag used to lock the modification of m_color.
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue