| Index: ppapi/proxy/compositor_layer_resource.cc
|
| diff --git a/ppapi/proxy/compositor_layer_resource.cc b/ppapi/proxy/compositor_layer_resource.cc
|
| index fb1bbe5139aa863c14d697558e12f15a9beb6b28..376227029cf24c1a0d00193011f4b183c1ccabdf 100644
|
| --- a/ppapi/proxy/compositor_layer_resource.cc
|
| +++ b/ppapi/proxy/compositor_layer_resource.cc
|
| @@ -45,6 +45,7 @@ float clamp(float value) {
|
| }
|
|
|
| void OnTextureReleased(
|
| + const scoped_refptr<CompositorResource> compositor,
|
| const ScopedPPResource& layer,
|
| const ScopedPPResource& context,
|
| uint32_t texture,
|
| @@ -73,6 +74,7 @@ void OnTextureReleased(
|
| }
|
|
|
| void OnImageReleased(
|
| + const scoped_refptr<CompositorResource> compositor,
|
| const ScopedPPResource& layer,
|
| const ScopedPPResource& image,
|
| const scoped_refptr<TrackedCallback>& release_callback,
|
| @@ -88,7 +90,7 @@ void OnImageReleased(
|
| CompositorLayerResource::CompositorLayerResource(
|
| Connection connection,
|
| PP_Instance instance,
|
| - const CompositorResource* compositor)
|
| + scoped_refptr<CompositorResource> compositor)
|
| : PluginResource(connection, instance),
|
| compositor_(compositor),
|
| source_size_(PP_MakeFloatSize(0.0f, 0.0f)) {
|
| @@ -112,6 +114,8 @@ int32_t CompositorLayerResource::SetColor(float red,
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -122,7 +126,6 @@ int32_t CompositorLayerResource::SetColor(float red,
|
| if (!size)
|
| return PP_ERROR_BADARGUMENT;
|
|
|
| -
|
| data_.color->red = clamp(red);
|
| data_.color->green = clamp(green);
|
| data_.color->blue = clamp(blue);
|
| @@ -177,8 +180,11 @@ int32_t CompositorLayerResource::SetTexture(
|
| // in this layer may still being used by chromium compositor. So we have to
|
| // use ScopedPPResource to keep this resource alive until the texture or image
|
| // is released by the chromium compositor.
|
| + // We also need keep the compositor alive, otherwise we will not receive
|
| + // the release IPC message for the texture.
|
| release_callback_ = base::Bind(
|
| &OnTextureReleased,
|
| + compositor_, // Keep compositor alive.
|
| ScopedPPResource(pp_resource()), // Keep layer alive.
|
| ScopedPPResource(context), // Keep context alive
|
| texture,
|
| @@ -225,8 +231,16 @@ int32_t CompositorLayerResource::SetImage(
|
| data_.image->source_rect.point = PP_MakeFloatPoint(0.0f, 0.0f);
|
| data_.image->source_rect.size = source_size_;
|
|
|
| + // If the PP_Resource of this layer is released by the plugin, the
|
| + // release_callback will be aborted immediately, but the texture or image
|
| + // in this layer may still being used by chromium compositor. So we have to
|
| + // use ScopedPPResource to keep this resource alive until the texture or image
|
| + // is released by the chromium compositor.
|
| + // We also need keep the compositor alive, otherwise we will not receive
|
| + // the release IPC message for the image.
|
| release_callback_ = base::Bind(
|
| &OnImageReleased,
|
| + compositor_, // Keep compositor alive.
|
| ScopedPPResource(pp_resource()), // Keep layer alive.
|
| ScopedPPResource(image_data), // Keep image_data alive.
|
| release_callback);
|
| @@ -238,6 +252,8 @@ int32_t CompositorLayerResource::SetClipRect(const PP_Rect* rect) {
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -249,6 +265,8 @@ int32_t CompositorLayerResource::SetTransform(const float matrix[16]) {
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -260,6 +278,8 @@ int32_t CompositorLayerResource::SetOpacity(float opacity) {
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -271,6 +291,8 @@ int32_t CompositorLayerResource::SetBlendMode(PP_BlendMode mode) {
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -288,6 +310,8 @@ int32_t CompositorLayerResource::SetSourceRect(
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -314,6 +338,8 @@ int32_t CompositorLayerResource::SetPremultipliedAlpha(PP_Bool premult) {
|
| if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
| @@ -351,9 +377,11 @@ bool CompositorLayerResource::SetType(LayerType type) {
|
| int32_t CompositorLayerResource::CheckForSetTextureAndImage(
|
| LayerType type,
|
| const scoped_refptr<TrackedCallback>& release_callback) {
|
| - if (!compositor_)
|
| + if (!compositor_)
|
| return PP_ERROR_BADRESOURCE;
|
|
|
| + CHECK(compositor_->bound_to_instance());
|
| +
|
| if (compositor_->IsInProgress())
|
| return PP_ERROR_INPROGRESS;
|
|
|
|
|