diff options
Diffstat (limited to 'ppapi/cpp')
-rw-r--r-- | ppapi/cpp/compositor_layer.cc | 54 | ||||
-rw-r--r-- | ppapi/cpp/compositor_layer.h | 2 |
2 files changed, 56 insertions, 0 deletions
diff --git a/ppapi/cpp/compositor_layer.cc b/ppapi/cpp/compositor_layer.cc index cbe823a..d15a673 100644 --- a/ppapi/cpp/compositor_layer.cc +++ b/ppapi/cpp/compositor_layer.cc @@ -17,6 +17,10 @@ template <> const char* interface_name<PPB_CompositorLayer_0_1>() { return PPB_COMPOSITORLAYER_INTERFACE_0_1; } +template <> const char* interface_name<PPB_CompositorLayer_0_2>() { + return PPB_COMPOSITORLAYER_INTERFACE_0_2; +} + } // namespace CompositorLayer::CompositorLayer() { @@ -43,6 +47,10 @@ int32_t CompositorLayer::SetColor(float red, float blue, float alpha, const Size& size) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetColor( + pp_resource(), red, green, blue, alpha, &size.pp_size()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetColor( pp_resource(), red, green, blue, alpha, &size.pp_size()); @@ -51,10 +59,18 @@ int32_t CompositorLayer::SetColor(float red, } int32_t CompositorLayer::SetTexture(const Graphics3D& context, + uint32_t target, uint32_t texture, const Size& size, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetTexture( + pp_resource(), context.pp_resource(), target, texture, &size.pp_size(), + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { + if (target != 0x0DE1) // 0x0DE1 GL_TEXTURE_2D + return cc.MayForce(PP_ERROR_NOTSUPPORTED); return get_interface<PPB_CompositorLayer_0_1>()->SetTexture( pp_resource(), context.pp_resource(), texture, &size.pp_size(), cc.pp_completion_callback()); @@ -64,6 +80,11 @@ int32_t CompositorLayer::SetTexture(const Graphics3D& context, int32_t CompositorLayer::SetImage(const ImageData& image, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetImage( + pp_resource(), image.pp_resource(), NULL, + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetImage( pp_resource(), image.pp_resource(), NULL, @@ -75,6 +96,11 @@ int32_t CompositorLayer::SetImage(const ImageData& image, int32_t CompositorLayer::SetImage(const ImageData& image, const Size& size, const CompletionCallback& cc) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetImage( + pp_resource(), image.pp_resource(), &size.pp_size(), + cc.pp_completion_callback()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetImage( pp_resource(), image.pp_resource(), &size.pp_size(), @@ -84,6 +110,10 @@ int32_t CompositorLayer::SetImage(const ImageData& image, } int32_t CompositorLayer::SetClipRect(const Rect& rect) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetClipRect( + pp_resource(), &rect.pp_rect()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetClipRect( pp_resource(), &rect.pp_rect()); @@ -92,6 +122,10 @@ int32_t CompositorLayer::SetClipRect(const Rect& rect) { } int32_t CompositorLayer::SetTransform(const float matrix[16]) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetTransform( + pp_resource(), matrix); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetTransform( pp_resource(), matrix); @@ -100,6 +134,10 @@ int32_t CompositorLayer::SetTransform(const float matrix[16]) { } int32_t CompositorLayer::SetOpacity(float opacity) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetOpacity( + pp_resource(), opacity); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetOpacity( pp_resource(), opacity); @@ -108,6 +146,10 @@ int32_t CompositorLayer::SetOpacity(float opacity) { } int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetBlendMode( + pp_resource(), mode); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetBlendMode( pp_resource(), mode); @@ -116,6 +158,10 @@ int32_t CompositorLayer::SetBlendMode(PP_BlendMode mode) { } int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetSourceRect( + pp_resource(), &rect.pp_float_rect()); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetSourceRect( pp_resource(), &rect.pp_float_rect()); @@ -124,6 +170,10 @@ int32_t CompositorLayer::SetSourceRect(const FloatRect& rect) { } int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return get_interface<PPB_CompositorLayer_0_2>()->SetPremultipliedAlpha( + pp_resource(), PP_FromBool(premult)); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return get_interface<PPB_CompositorLayer_0_1>()->SetPremultipliedAlpha( pp_resource(), PP_FromBool(premult)); @@ -132,6 +182,10 @@ int32_t CompositorLayer::SetPremultipliedAlpha(bool premult) { } bool CompositorLayer::IsCompositorLayer(const Resource& resource) { + if (has_interface<PPB_CompositorLayer_0_2>()) { + return PP_ToBool(get_interface<PPB_CompositorLayer_0_2>()-> + IsCompositorLayer(resource.pp_resource())); + } if (has_interface<PPB_CompositorLayer_0_1>()) { return PP_ToBool(get_interface<PPB_CompositorLayer_0_1>()-> IsCompositorLayer(resource.pp_resource())); diff --git a/ppapi/cpp/compositor_layer.h b/ppapi/cpp/compositor_layer.h index f431bd8..9e65e87 100644 --- a/ppapi/cpp/compositor_layer.h +++ b/ppapi/cpp/compositor_layer.h @@ -70,6 +70,7 @@ class CompositorLayer : public Resource { /// /// param[in] context A <code>Graphics3D</code> corresponding to a graphics 3d /// resource which owns the GL texture. + /// param[in] target GL texture target (GL_TEXTURE_2D, etc). /// param[in] texture A GL texture object id. /// param[in] size A <code>Size</code> for the size of the layer before /// transform. @@ -78,6 +79,7 @@ class CompositorLayer : public Resource { /// /// @return An int32_t containing a result code from <code>pp_errors.h</code>. int32_t SetTexture(const Graphics3D& context, + uint32_t target, uint32_t texture, const Size& size, const CompletionCallback& cc); |