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

Side by Side Diff: ppapi/proxy/compositor_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: Remove change in base folder. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/compositor_resource.h" 5 #include "ppapi/proxy/compositor_resource.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ppapi/proxy/ppapi_messages.h" 8 #include "ppapi/proxy/ppapi_messages.h"
9 #include "ppapi/thunk/enter.h"
9 10
10 namespace ppapi { 11 namespace ppapi {
11 namespace proxy { 12 namespace proxy {
12 13
13 CompositorResource::CompositorResource(Connection connection, 14 CompositorResource::CompositorResource(Connection connection,
14 PP_Instance instance) 15 PP_Instance instance)
15 : PluginResource(connection, instance), 16 : PluginResource(connection, instance),
16 layer_reset_(true), 17 layer_reset_(true),
17 last_resource_id_(0) { 18 last_resource_id_(0) {
18 SendCreate(RENDERER, PpapiHostMsg_Compositor_Create()); 19 SendCreate(RENDERER, PpapiHostMsg_Compositor_Create());
19 } 20 }
20 21
22 bool CompositorResource::IsInProgress() const {
23 ProxyLock::AssertAcquiredDebugOnly();
24 return TrackedCallback::IsPending(commit_callback_);
25 }
26
27 int32_t CompositorResource::GenerateResourceId() const {
28 ProxyLock::AssertAcquiredDebugOnly();
29 return ++last_resource_id_;
30 }
31
21 CompositorResource::~CompositorResource() { 32 CompositorResource::~CompositorResource() {
22 ResetLayersInternal(); 33 ResetLayersInternal();
23 } 34 }
24 35
25 thunk::PPB_Compositor_API* CompositorResource::AsPPB_Compositor_API() { 36 thunk::PPB_Compositor_API* CompositorResource::AsPPB_Compositor_API() {
26 return this; 37 return this;
27 } 38 }
28 39
29 void CompositorResource::OnReplyReceived( 40 void CompositorResource::OnReplyReceived(
30 const ResourceMessageReplyParams& params, 41 const ResourceMessageReplyParams& params,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 base::Bind(&CompositorResource::OnPluginMsgCommitLayersReply, 78 base::Bind(&CompositorResource::OnPluginMsgCommitLayersReply,
68 base::Unretained(this)), 79 base::Unretained(this)),
69 callback); 80 callback);
70 81
71 return PP_OK_COMPLETIONPENDING; 82 return PP_OK_COMPLETIONPENDING;
72 } 83 }
73 84
74 int32_t CompositorResource::ResetLayers() { 85 int32_t CompositorResource::ResetLayers() {
75 if (IsInProgress()) 86 if (IsInProgress())
76 return PP_ERROR_INPROGRESS; 87 return PP_ERROR_INPROGRESS;
88
77 ResetLayersInternal(); 89 ResetLayersInternal();
78 return PP_OK; 90 return PP_OK;
79 } 91 }
80 92
93 void CompositorResource::NotifyLastPluginRefWasDeleted() {
94 PluginResource::NotifyLastPluginRefWasDeleted();
95 ResetLayersInternal();
96 // The resource dtor sends an IPC message to renderer, and then the renderer
97 // will delete the resource host.
98 // But in this case, every callback in |release_callback_map_| holds a
99 // scoped_refptr of the compositor resource, so the compositor will never be
piman 2014/06/19 20:44:04 Well, maybe that is the problem we should fix. Ess
Peng 2014/06/19 22:33:41 Done
100 // deleted. We have to ask the compositor resource host to release all layers,
101 // and then all all release callbacks will be called, and then the compositor
102 // resource will be deleted.
103 Post(RENDERER, PpapiHostMsg_Compositor_Release());
104 }
105
81 void CompositorResource::OnPluginMsgCommitLayersReply( 106 void CompositorResource::OnPluginMsgCommitLayersReply(
82 const ResourceMessageReplyParams& params) { 107 const ResourceMessageReplyParams& params) {
83 if (!TrackedCallback::IsPending(commit_callback_)) 108 if (!TrackedCallback::IsPending(commit_callback_))
84 return; 109 return;
85 110
86 // On success, we put layers' release_callbacks into a map, 111 // On success, we put layers' release_callbacks into a map,
87 // otherwise we will do nothing. So plugin may change layers and 112 // otherwise we will do nothing. So plugin may change layers and
88 // call CommitLayers() again. 113 // call CommitLayers() again.
89 if (params.result() == PP_OK) { 114 if (params.result() == PP_OK) {
90 layer_reset_ = false; 115 layer_reset_ = false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 151 }
127 (*it)->Invalidate(); 152 (*it)->Invalidate();
128 } 153 }
129 154
130 layers_.clear(); 155 layers_.clear();
131 layer_reset_ = true; 156 layer_reset_ = true;
132 } 157 }
133 158
134 } // namespace proxy 159 } // namespace proxy
135 } // namespace ppapi 160 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698