Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: ppapi/proxy/compositor_layer_resource.cc

Issue 324983005: [PPAPI] Add browser tests for compositor API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compositor_api_impl_new
Patch Set: Fix review issues Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
raymes 2014/06/18 05:58:44 nit: move to previous line
Peng 2014/06/18 11:14:37 Done.
raymes 2014/06/19 00:39:13 what I meant was to fill up the 80 characters on t
Peng 2014/06/19 17:35:11 Done.
+ // 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.
raymes 2014/06/19 00:39:13 Same here.
Peng 2014/06/19 17:35:11 Done.
release_callback_ = base::Bind(
&OnImageReleased,
+ compositor_, // Keep compositor alive.
ScopedPPResource(pp_resource()), // Keep layer alive.
ScopedPPResource(image_data), // Keep image_data alive.
raymes 2014/06/18 05:58:44 Can these all be scoped_refptr rather than ScopedP
Peng 2014/06/18 11:14:37 completion_callback is aborted, when the PP_Resour
raymes 2014/06/19 00:39:13 I think that holding a ref to the resource should
Peng 2014/06/19 17:35:11 The Reosurce's ctor and dtor use AddResource() and
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;

Powered by Google App Engine
This is Rietveld 408576698