Index: cc/output/program_binding.h |
diff --git a/cc/output/program_binding.h b/cc/output/program_binding.h |
index 912329ef6bf548055ad6a07de577f12040af4936..fd889293ee1e351926a231533b2a24223fb76915 100644 |
--- a/cc/output/program_binding.h |
+++ b/cc/output/program_binding.h |
@@ -98,6 +98,56 @@ class ProgramBinding : public ProgramBindingBase { |
DISALLOW_COPY_AND_ASSIGN(ProgramBinding); |
}; |
+template <class VertexShader, class FragmentShader> |
+class ProgramBindingWithBlendMode : public ProgramBindingBase { |
+ public: |
+ ProgramBindingWithBlendMode() {} |
+ |
+ void Initialize(ContextProvider* context_provider, |
+ TexCoordPrecision precision, |
+ SamplerType sampler, |
+ SkXfermode::Mode blend_mode) { |
+ DCHECK(context_provider); |
+ DCHECK(!initialized_); |
+ |
+ if (context_provider->IsContextLost()) |
+ return; |
+ |
+ if (!ProgramBindingBase::Init( |
+ context_provider->ContextGL(), |
+ vertex_shader_.GetShaderString(), |
+ fragment_shader_.GetShaderString(precision, sampler, blend_mode))) { |
+ DCHECK(context_provider->IsContextLost()); |
+ return; |
+ } |
+ |
+ int base_uniform_index = 0; |
+ vertex_shader_.Init( |
+ context_provider->ContextGL(), program_, &base_uniform_index); |
+ fragment_shader_.Init(context_provider->ContextGL(), |
+ program_, |
+ &base_uniform_index, |
+ blend_mode != SkXfermode::kSrcOver_Mode); |
+ |
+ // Link after binding uniforms |
+ if (!Link(context_provider->ContextGL())) { |
+ DCHECK(context_provider->IsContextLost()); |
+ return; |
+ } |
+ |
+ initialized_ = true; |
+ } |
+ |
+ const VertexShader& vertex_shader() const { return vertex_shader_; } |
enne (OOO)
2014/09/24 22:07:56
Why shadow the base class with these functions and
|
+ const FragmentShader& fragment_shader() const { return fragment_shader_; } |
+ |
+ private: |
+ VertexShader vertex_shader_; |
+ FragmentShader fragment_shader_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ProgramBindingWithBlendMode); |
+}; |
+ |
} // namespace cc |
#endif // CC_OUTPUT_PROGRAM_BINDING_H_ |