diff options
author | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 21:30:16 +0000 |
---|---|---|
committer | penghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-15 21:30:16 +0000 |
commit | 748e647a09bf44eb993022f31495efd5b58e7d3d (patch) | |
tree | 1e6eff45da50fab026a4a6b1ffd33803cd399ad2 | |
parent | 032ed0d7869d3ad0569a2024eaa4946864cc7f9d (diff) | |
download | chromium_src-748e647a09bf44eb993022f31495efd5b58e7d3d.zip chromium_src-748e647a09bf44eb993022f31495efd5b58e7d3d.tar.gz chromium_src-748e647a09bf44eb993022f31495efd5b58e7d3d.tar.bz2 |
[PPAPI] Add target param for CompositorLayer::SetTexture().
BUG=403504
Review URL: https://codereview.chromium.org/475123003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290016 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/pepper/pepper_compositor_host.cc | 2 | ||||
-rw-r--r-- | ppapi/api/ppb_compositor_layer.idl | 31 | ||||
-rw-r--r-- | ppapi/c/pp_macros.h | 4 | ||||
-rw-r--r-- | ppapi/c/ppb_compositor_layer.h | 32 | ||||
-rw-r--r-- | ppapi/cpp/compositor_layer.cc | 54 | ||||
-rw-r--r-- | ppapi/cpp/compositor_layer.h | 2 | ||||
-rw-r--r-- | ppapi/examples/compositor/compositor.cc | 10 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 75 | ||||
-rw-r--r-- | ppapi/proxy/compositor_layer_resource.cc | 19 | ||||
-rw-r--r-- | ppapi/proxy/compositor_layer_resource.h | 6 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 1 | ||||
-rw-r--r-- | ppapi/shared_impl/compositor_layer_data.h | 4 | ||||
-rw-r--r-- | ppapi/tests/test_compositor.cc | 12 | ||||
-rw-r--r-- | ppapi/thunk/ppb_compositor_layer_api.h | 6 | ||||
-rw-r--r-- | ppapi/thunk/ppb_compositor_layer_thunk.cc | 37 |
15 files changed, 280 insertions, 15 deletions
diff --git a/content/renderer/pepper/pepper_compositor_host.cc b/content/renderer/pepper/pepper_compositor_host.cc index f7e32b6..6116a36 100644 --- a/content/renderer/pepper/pepper_compositor_host.cc +++ b/content/renderer/pepper/pepper_compositor_host.cc @@ -252,7 +252,7 @@ void PepperCompositorHost::UpdateLayer( if (!old_layer || new_layer->common.resource_id != old_layer->common.resource_id) { cc::TextureMailbox mailbox(new_layer->texture->mailbox, - GL_TEXTURE_2D, + new_layer->texture->target, new_layer->texture->sync_point); texture_layer->SetTextureMailbox(mailbox, cc::SingleReleaseCallback::Create( diff --git a/ppapi/api/ppb_compositor_layer.idl b/ppapi/api/ppb_compositor_layer.idl index a457ccc..ed0967d 100644 --- a/ppapi/api/ppb_compositor_layer.idl +++ b/ppapi/api/ppb_compositor_layer.idl @@ -6,7 +6,8 @@ [generate_thunk] label Chrome { - [channel=dev] M37 = 0.1 + [channel=dev] M37 = 0.1, + [channel=dev] M38 = 0.2 }; /** @@ -108,6 +109,34 @@ interface PPB_CompositorLayer { [in] PP_CompletionCallback cc); /** + * Sets the texture of a texture layer. If the layer is uninitialized, + * it will initialize the layer first, and then set its texture. + * The source rect will be set to ((0, 0), (1, 1)). If the layer has been + * initialized to another kind of layer, the layer will not be changed, + * and <code>PP_ERROR_BADARGUMENT</code> will be returned. + * + * param[in] layer A <code>PP_Resource</code> corresponding to a compositor + * layer resource. + * param[in] context A <code>PP_Resource</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>PP_Size</code> for the size of the layer before + * transform. + * param[in] cc A <code>PP_CompletionCallback</code> to be called when + * the texture is released by Chromium compositor. + * + * @return An int32_t containing a result code from <code>pp_errors.h</code>. + */ + [version = 0.2] + int32_t SetTexture([in] PP_Resource layer, + [in] PP_Resource context, + [in] uint32_t target, + [in] uint32_t texture, + [in] PP_Size size, + [in] PP_CompletionCallback cc); + + /** * Sets the image of an image layer. If the layer is uninitialized, * it will initialize the layer first, and then set its image. * The layer size will be set to the image's size. The source rect will be set diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h index 31d7297..ea355fa 100644 --- a/ppapi/c/pp_macros.h +++ b/ppapi/c/pp_macros.h @@ -3,13 +3,13 @@ * found in the LICENSE file. */ -/* From pp_macros.idl modified Tue May 20 17:13:23 2014. */ +/* From pp_macros.idl modified Wed Jun 11 11:38:24 2014. */ #ifndef PPAPI_C_PP_MACROS_H_ #define PPAPI_C_PP_MACROS_H_ -#define PPAPI_RELEASE 37 +#define PPAPI_RELEASE 38 /** * @file diff --git a/ppapi/c/ppb_compositor_layer.h b/ppapi/c/ppb_compositor_layer.h index 8fcb1ab..25d2ebc 100644 --- a/ppapi/c/ppb_compositor_layer.h +++ b/ppapi/c/ppb_compositor_layer.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_compositor_layer.idl modified Wed Jun 4 11:17:54 2014. */ +/* From ppb_compositor_layer.idl modified Thu Aug 14 18:06:33 2014. */ #ifndef PPAPI_C_PPB_COMPOSITOR_LAYER_H_ #define PPAPI_C_PPB_COMPOSITOR_LAYER_H_ @@ -18,6 +18,7 @@ #include "ppapi/c/pp_stdint.h" #define PPB_COMPOSITORLAYER_INTERFACE_0_1 "PPB_CompositorLayer;0.1" /* dev */ +#define PPB_COMPOSITORLAYER_INTERFACE_0_2 "PPB_CompositorLayer;0.2" /* dev */ /** * @file */ @@ -65,7 +66,7 @@ typedef enum { * Defines the <code>PPB_CompositorLayer</code> interface. It is used by * <code>PPB_Compositor</code>. */ -struct PPB_CompositorLayer_0_1 { /* dev */ +struct PPB_CompositorLayer_0_2 { /* dev */ /** * Determines if a resource is a compositor layer resource. * @@ -114,6 +115,7 @@ struct PPB_CompositorLayer_0_1 { /* dev */ * layer resource. * param[in] context A <code>PP_Resource</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>PP_Size</code> for the size of the layer before * transform. @@ -124,6 +126,7 @@ struct PPB_CompositorLayer_0_1 { /* dev */ */ int32_t (*SetTexture)(PP_Resource layer, PP_Resource context, + uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc); @@ -228,6 +231,31 @@ struct PPB_CompositorLayer_0_1 { /* dev */ */ int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult); }; + +struct PPB_CompositorLayer_0_1 { /* dev */ + PP_Bool (*IsCompositorLayer)(PP_Resource resource); + int32_t (*SetColor)(PP_Resource layer, + float red, + float green, + float blue, + float alpha, + const struct PP_Size* size); + int32_t (*SetTexture)(PP_Resource layer, + PP_Resource context, + uint32_t texture, + const struct PP_Size* size, + struct PP_CompletionCallback cc); + int32_t (*SetImage)(PP_Resource layer, + PP_Resource image_data, + const struct PP_Size* size, + struct PP_CompletionCallback cc); + int32_t (*SetClipRect)(PP_Resource layer, const struct PP_Rect* rect); + int32_t (*SetTransform)(PP_Resource layer, const float matrix[16]); + int32_t (*SetOpacity)(PP_Resource layer, float opacity); + int32_t (*SetBlendMode)(PP_Resource layer, PP_BlendMode mode); + int32_t (*SetSourceRect)(PP_Resource layer, const struct PP_FloatRect* rect); + int32_t (*SetPremultipliedAlpha)(PP_Resource layer, PP_Bool premult); +}; /** * @} */ 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); diff --git a/ppapi/examples/compositor/compositor.cc b/ppapi/examples/compositor/compositor.cc index e7e3f1f..d13e48a 100644 --- a/ppapi/examples/compositor/compositor.cc +++ b/ppapi/examples/compositor/compositor.cc @@ -351,7 +351,9 @@ void DemoInstance::PrepareLayers(int32_t frame) { cube_->Draw(); rv = stable_texture_layer_.SetTexture( *context_, - texture, pp::Size(600, 600), + GL_TEXTURE_2D, + texture, + pp::Size(600, 600), callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, texture)); assert(rv == PP_OK_COMPLETIONPENDING); @@ -397,7 +399,11 @@ void DemoInstance::PrepareLayers(int32_t frame) { GLuint texture = PrepareFramebuffer(); cube_->UpdateForTimeDelta(0.02f); cube_->Draw(); - rv = texture_layer_.SetTexture(*context_, texture, pp::Size(400, 400), + rv = texture_layer_.SetTexture( + *context_, + GL_TEXTURE_2D, + texture, + pp::Size(400, 400), callback_factory_.NewCallback(&DemoInstance::OnTextureReleased, texture)); assert(rv == PP_OK_COMPLETIONPENDING); diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 16a3a90..245b3bc 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -97,6 +97,7 @@ static int mystrcmp(const char* s1, const char *s2) { static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Compositor_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_1; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Core_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileIO_1_0; @@ -296,6 +297,60 @@ static int32_t Pnacl_M37_PPB_CompositorLayer_SetPremultipliedAlpha(PP_Resource l /* End wrapper methods for PPB_CompositorLayer_0_1 */ +/* Begin wrapper methods for PPB_CompositorLayer_0_2 */ + +static PP_Bool Pnacl_M38_PPB_CompositorLayer_IsCompositorLayer(PP_Resource resource) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->IsCompositorLayer(resource); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetColor(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetColor(layer, red, green, blue, alpha, size); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetTexture(PP_Resource layer, PP_Resource context, uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback* cc) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetTexture(layer, context, target, texture, size, *cc); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetImage(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback* cc) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetImage(layer, image_data, size, *cc); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetClipRect(PP_Resource layer, const struct PP_Rect* rect) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetClipRect(layer, rect); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetTransform(PP_Resource layer, const float matrix[16]) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetTransform(layer, matrix); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetOpacity(PP_Resource layer, float opacity) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetOpacity(layer, opacity); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetBlendMode(PP_Resource layer, PP_BlendMode mode) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetBlendMode(layer, mode); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetSourceRect(PP_Resource layer, const struct PP_FloatRect* rect) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetSourceRect(layer, rect); +} + +static int32_t Pnacl_M38_PPB_CompositorLayer_SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) { + const struct PPB_CompositorLayer_0_2 *iface = Pnacl_WrapperInfo_PPB_CompositorLayer_0_2.real_iface; + return iface->SetPremultipliedAlpha(layer, premult); +} + +/* End wrapper methods for PPB_CompositorLayer_0_2 */ + /* Begin wrapper methods for PPB_Console_1_0 */ static void Pnacl_M25_PPB_Console_Log(PP_Instance instance, PP_LogLevel level, struct PP_Var* value) { @@ -4369,6 +4424,19 @@ static const struct PPB_CompositorLayer_0_1 Pnacl_Wrappers_PPB_CompositorLayer_0 .SetPremultipliedAlpha = (int32_t (*)(PP_Resource layer, PP_Bool premult))&Pnacl_M37_PPB_CompositorLayer_SetPremultipliedAlpha }; +static const struct PPB_CompositorLayer_0_2 Pnacl_Wrappers_PPB_CompositorLayer_0_2 = { + .IsCompositorLayer = (PP_Bool (*)(PP_Resource resource))&Pnacl_M38_PPB_CompositorLayer_IsCompositorLayer, + .SetColor = (int32_t (*)(PP_Resource layer, float red, float green, float blue, float alpha, const struct PP_Size* size))&Pnacl_M38_PPB_CompositorLayer_SetColor, + .SetTexture = (int32_t (*)(PP_Resource layer, PP_Resource context, uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M38_PPB_CompositorLayer_SetTexture, + .SetImage = (int32_t (*)(PP_Resource layer, PP_Resource image_data, const struct PP_Size* size, struct PP_CompletionCallback cc))&Pnacl_M38_PPB_CompositorLayer_SetImage, + .SetClipRect = (int32_t (*)(PP_Resource layer, const struct PP_Rect* rect))&Pnacl_M38_PPB_CompositorLayer_SetClipRect, + .SetTransform = (int32_t (*)(PP_Resource layer, const float matrix[16]))&Pnacl_M38_PPB_CompositorLayer_SetTransform, + .SetOpacity = (int32_t (*)(PP_Resource layer, float opacity))&Pnacl_M38_PPB_CompositorLayer_SetOpacity, + .SetBlendMode = (int32_t (*)(PP_Resource layer, PP_BlendMode mode))&Pnacl_M38_PPB_CompositorLayer_SetBlendMode, + .SetSourceRect = (int32_t (*)(PP_Resource layer, const struct PP_FloatRect* rect))&Pnacl_M38_PPB_CompositorLayer_SetSourceRect, + .SetPremultipliedAlpha = (int32_t (*)(PP_Resource layer, PP_Bool premult))&Pnacl_M38_PPB_CompositorLayer_SetPremultipliedAlpha +}; + static const struct PPB_Console_1_0 Pnacl_Wrappers_PPB_Console_1_0 = { .Log = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var value))&Pnacl_M25_PPB_Console_Log, .LogWithSource = (void (*)(PP_Instance instance, PP_LogLevel level, struct PP_Var source, struct PP_Var value))&Pnacl_M25_PPB_Console_LogWithSource @@ -5503,6 +5571,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_1 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_CompositorLayer_0_2 = { + .iface_macro = PPB_COMPOSITORLAYER_INTERFACE_0_2, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_CompositorLayer_0_2, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Console_1_0 = { .iface_macro = PPB_CONSOLE_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Console_1_0, @@ -6130,6 +6204,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1 = { static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Compositor_0_1, &Pnacl_WrapperInfo_PPB_CompositorLayer_0_1, + &Pnacl_WrapperInfo_PPB_CompositorLayer_0_2, &Pnacl_WrapperInfo_PPB_Console_1_0, &Pnacl_WrapperInfo_PPB_Core_1_0, &Pnacl_WrapperInfo_PPB_FileIO_1_0, diff --git a/ppapi/proxy/compositor_layer_resource.cc b/ppapi/proxy/compositor_layer_resource.cc index 17bc7b2..09a63b1 100644 --- a/ppapi/proxy/compositor_layer_resource.cc +++ b/ppapi/proxy/compositor_layer_resource.cc @@ -5,6 +5,7 @@ #include "ppapi/proxy/compositor_layer_resource.h" #include "base/logging.h" +#include "gpu/GLES2/gl2extchromium.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/common/mailbox.h" #include "ppapi/proxy/compositor_resource.h" @@ -121,8 +122,17 @@ int32_t CompositorLayerResource::SetColor(float red, return PP_OK; } +int32_t CompositorLayerResource::SetTexture0_1( + PP_Resource context, + uint32_t texture, + const PP_Size* size, + const scoped_refptr<TrackedCallback>& release_callback) { + return SetTexture(context, GL_TEXTURE_2D, texture, size, release_callback); +} + int32_t CompositorLayerResource::SetTexture( PP_Resource context, + uint32_t target, uint32_t texture, const PP_Size* size, const scoped_refptr<TrackedCallback>& release_callback) { @@ -135,6 +145,12 @@ int32_t CompositorLayerResource::SetTexture( if (enter.failed()) return PP_ERROR_BADRESOURCE; + if (target != GL_TEXTURE_2D && + target != GL_TEXTURE_EXTERNAL_OES && + target != GL_TEXTURE_RECTANGLE_ARB) { + return PP_ERROR_BADARGUMENT; + } + if (!size || size->width <= 0 || size->height <= 0) return PP_ERROR_BADARGUMENT; @@ -147,7 +163,7 @@ int32_t CompositorLayerResource::SetTexture( gl->GenMailboxCHROMIUM( reinterpret_cast<GLbyte*>(data_.texture->mailbox.name)); gl->ProduceTextureDirectCHROMIUM( - texture, GL_TEXTURE_2D, + texture, target, reinterpret_cast<const GLbyte*>(data_.texture->mailbox.name)); // Set the source size to (1, 1). It will be used to verify the source_rect @@ -156,6 +172,7 @@ int32_t CompositorLayerResource::SetTexture( data_.common.size = *size; data_.common.resource_id = compositor_->GenerateResourceId(); + data_.texture->target = target; data_.texture->sync_point = gl->InsertSyncPointCHROMIUM(); data_.texture->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f); data_.texture->source_rect.size = source_size_; diff --git a/ppapi/proxy/compositor_layer_resource.h b/ppapi/proxy/compositor_layer_resource.h index a31d8fe..09f5d81 100644 --- a/ppapi/proxy/compositor_layer_resource.h +++ b/ppapi/proxy/compositor_layer_resource.h @@ -53,8 +53,14 @@ class PPAPI_PROXY_EXPORT CompositorLayerResource float blue, float alpha, const PP_Size* size) OVERRIDE; + virtual int32_t SetTexture0_1( + PP_Resource context, + uint32_t texture, + const PP_Size* size, + const scoped_refptr<ppapi::TrackedCallback>& callback) OVERRIDE; virtual int32_t SetTexture( PP_Resource context, + uint32_t target, uint32_t texture, const PP_Size* size, const scoped_refptr<TrackedCallback>& callback) OVERRIDE; diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 2090d36a..7747abf 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -264,6 +264,7 @@ IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(ppapi::CompositorLayerData::TextureLayer) IPC_STRUCT_TRAITS_MEMBER(mailbox) + IPC_STRUCT_TRAITS_MEMBER(target) IPC_STRUCT_TRAITS_MEMBER(sync_point) IPC_STRUCT_TRAITS_MEMBER(source_rect) IPC_STRUCT_TRAITS_MEMBER(premult_alpha) diff --git a/ppapi/shared_impl/compositor_layer_data.h b/ppapi/shared_impl/compositor_layer_data.h index b51fcd7..8cf096e 100644 --- a/ppapi/shared_impl/compositor_layer_data.h +++ b/ppapi/shared_impl/compositor_layer_data.h @@ -78,11 +78,13 @@ struct PPAPI_SHARED_EXPORT CompositorLayerData { struct TextureLayer { TextureLayer() - : sync_point(0), + : target(0), + sync_point(0), source_rect(PP_MakeFloatRectFromXYWH(0.0f, 0.0f, 1.0f, 1.0f)), premult_alpha(true) {} gpu::Mailbox mailbox; + uint32_t target; uint32_t sync_point; PP_FloatRect source_rect; bool premult_alpha; diff --git a/ppapi/tests/test_compositor.cc b/ppapi/tests/test_compositor.cc index e844e8d..ba2b5ed 100644 --- a/ppapi/tests/test_compositor.cc +++ b/ppapi/tests/test_compositor.cc @@ -122,7 +122,8 @@ std::string TestCompositor::TestBindUnbind() { TestCompletionCallback texture_release_callback(instance_->pp_instance(), PP_REQUIRED); ASSERT_EQ(PP_OK_COMPLETIONPENDING, - texture_layer.SetTexture(graphics_3d, texture, pp::Size(100, 100), + texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture, + pp::Size(100, 100), texture_release_callback.GetCallback())); pp::ImageData image; @@ -201,7 +202,8 @@ std::string TestCompositor::TestReleaseInternal(bool bind) { TestCompletionCallback texture_release_callback(instance_->pp_instance(), PP_REQUIRED); ASSERT_EQ(PP_OK_COMPLETIONPENDING, - texture_layer.SetTexture(graphics_3d, texture, pp::Size(100, 100), + texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture, + pp::Size(100, 100), texture_release_callback.GetCallback())); pp::ImageData image; @@ -265,7 +267,8 @@ std::string TestCompositor::TestReleaseWithoutCommitInternal(bool bind) { TestCompletionCallback texture_release_callback(instance_->pp_instance(), PP_REQUIRED); ASSERT_EQ(PP_OK_COMPLETIONPENDING, - texture_layer.SetTexture(graphics_3d, texture, pp::Size(100, 100), + texture_layer.SetTexture(graphics_3d, GL_TEXTURE_2D, texture, + pp::Size(100, 100), texture_release_callback.GetCallback())); pp::ImageData image; @@ -347,7 +350,8 @@ std::string TestCompositor::TestGeneralInternal(bool bind) { TestCompletionCallback texture_release_callback(instance_->pp_instance(), PP_REQUIRED); ASSERT_EQ(PP_OK_COMPLETIONPENDING, - texture_layer.SetTexture(graphics_3d, texture, pp::Size(100, 100), + texture_layer.SetTexture(graphics_3d, texture, GL_TEXTURE_2D, + pp::Size(100, 100), texture_release_callback.GetCallback())); pp::ImageData image; diff --git a/ppapi/thunk/ppb_compositor_layer_api.h b/ppapi/thunk/ppb_compositor_layer_api.h index e59f632..23635f3 100644 --- a/ppapi/thunk/ppb_compositor_layer_api.h +++ b/ppapi/thunk/ppb_compositor_layer_api.h @@ -20,8 +20,14 @@ class PPAPI_THUNK_EXPORT PPB_CompositorLayer_API { float blue, float alpha, const PP_Size* size) = 0; + virtual int32_t SetTexture0_1( + PP_Resource context, + uint32_t texture, + const PP_Size* size, + const scoped_refptr<ppapi::TrackedCallback>& callback) = 0; virtual int32_t SetTexture( PP_Resource context, + uint32_t target, uint32_t texture, const PP_Size* size, const scoped_refptr<ppapi::TrackedCallback>& callback) = 0; diff --git a/ppapi/thunk/ppb_compositor_layer_thunk.cc b/ppapi/thunk/ppb_compositor_layer_thunk.cc index 4923fea..f0a98df 100644 --- a/ppapi/thunk/ppb_compositor_layer_thunk.cc +++ b/ppapi/thunk/ppb_compositor_layer_thunk.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From ppb_compositor_layer.idl modified Wed Jun 4 11:17:54 2014. +// From ppb_compositor_layer.idl modified Thu Aug 14 18:06:33 2014. #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -36,8 +36,24 @@ int32_t SetColor(PP_Resource layer, return enter.object()->SetColor(red, green, blue, alpha, size); } +int32_t SetTexture_0_1(PP_Resource layer, + PP_Resource context, + uint32_t texture, + const struct PP_Size* size, + struct PP_CompletionCallback cc) { + VLOG(4) << "PPB_CompositorLayer::SetTexture()"; + EnterResource<PPB_CompositorLayer_API> enter(layer, cc, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->SetTexture0_1(context, + texture, + size, + enter.callback())); +} + int32_t SetTexture(PP_Resource layer, PP_Resource context, + uint32_t target, uint32_t texture, const struct PP_Size* size, struct PP_CompletionCallback cc) { @@ -46,6 +62,7 @@ int32_t SetTexture(PP_Resource layer, if (enter.failed()) return enter.retval(); return enter.SetResult(enter.object()->SetTexture(context, + target, texture, size, enter.callback())); @@ -115,6 +132,19 @@ int32_t SetPremultipliedAlpha(PP_Resource layer, PP_Bool premult) { const PPB_CompositorLayer_0_1 g_ppb_compositorlayer_thunk_0_1 = { &IsCompositorLayer, &SetColor, + &SetTexture_0_1, + &SetImage, + &SetClipRect, + &SetTransform, + &SetOpacity, + &SetBlendMode, + &SetSourceRect, + &SetPremultipliedAlpha +}; + +const PPB_CompositorLayer_0_2 g_ppb_compositorlayer_thunk_0_2 = { + &IsCompositorLayer, + &SetColor, &SetTexture, &SetImage, &SetClipRect, @@ -132,5 +162,10 @@ PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_1* return &g_ppb_compositorlayer_thunk_0_1; } +PPAPI_THUNK_EXPORT const PPB_CompositorLayer_0_2* + GetPPB_CompositorLayer_0_2_Thunk() { + return &g_ppb_compositorlayer_thunk_0_2; +} + } // namespace thunk } // namespace ppapi |