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

Side by Side Diff: ppapi/shared_impl/video_decoder_impl.cc

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/shared_impl/video_decoder_impl.h" 5 #include "ppapi/shared_impl/video_decoder_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/client/gles2_implementation.h" 8 #include "gpu/command_buffer/client/gles2_implementation.h"
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/proxy/plugin_resource_tracker.h" 10 #include "ppapi/proxy/plugin_resource_tracker.h"
11 #include "ppapi/shared_impl/resource_tracker.h"
11 #include "ppapi/thunk/ppb_context_3d_api.h" 12 #include "ppapi/thunk/ppb_context_3d_api.h"
12 #include "ppapi/thunk/enter.h" 13 #include "ppapi/thunk/enter.h"
13 14
14 using ppapi::thunk::PPB_Context3D_API; 15 using ppapi::thunk::PPB_Context3D_API;
15 16
16 namespace ppapi { 17 namespace ppapi {
17 18
18 VideoDecoderImpl::VideoDecoderImpl() 19 VideoDecoderImpl::VideoDecoderImpl()
19 : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)), 20 : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)),
20 reset_callback_(PP_MakeCompletionCallback(NULL, NULL)), 21 reset_callback_(PP_MakeCompletionCallback(NULL, NULL)),
21 context3d_id_(0), 22 context3d_id_(0),
22 gles2_impl_(NULL) { 23 gles2_impl_(NULL) {
23 } 24 }
24 25
25 VideoDecoderImpl::~VideoDecoderImpl() { 26 VideoDecoderImpl::~VideoDecoderImpl() {
26 } 27 }
27 28
28 bool VideoDecoderImpl::Init(PP_Resource context3d_id, 29 bool VideoDecoderImpl::Init(PP_Resource context3d_id,
29 PPB_Context3D_API* context3d, 30 PPB_Context3D_API* context3d,
30 const PP_VideoConfigElement* decoder_config) { 31 const PP_VideoConfigElement* decoder_config) {
31 if (!context3d || !decoder_config || !context3d_id) 32 if (!context3d || !decoder_config || !context3d_id)
32 return false; 33 return false;
33 34
34 DCHECK(!gles2_impl_ && !context3d_id_); 35 DCHECK(!gles2_impl_ && !context3d_id_);
35 gles2_impl_ = context3d->GetGLES2Impl(); 36 gles2_impl_ = context3d->GetGLES2Impl();
36 AddRefResource(context3d_id); 37 TrackerBase::Get()->GetResourceTracker()->AddRefResource(context3d_id);
37 context3d_id_ = context3d_id; 38 context3d_id_ = context3d_id;
38 return true; 39 return true;
39 } 40 }
40 41
41 void VideoDecoderImpl::Destroy() { 42 void VideoDecoderImpl::Destroy() {
42 context3d_id_ = 0; 43 context3d_id_ = 0;
43 gles2_impl_ = NULL; 44 gles2_impl_ = NULL;
44 UnrefResource(context3d_id_); 45 TrackerBase::Get()->GetResourceTracker()->ReleaseResource(context3d_id_);
45 } 46 }
46 47
47 bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) { 48 bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) {
48 CHECK(callback.func); 49 CHECK(callback.func);
49 if (flush_callback_.func) 50 if (flush_callback_.func)
50 return false; 51 return false;
51 flush_callback_ = callback; 52 flush_callback_ = callback;
52 return true; 53 return true;
53 } 54 }
54 55
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 const PP_VideoConfigElement* current = configs_to_copy; 101 const PP_VideoConfigElement* current = configs_to_copy;
101 while (current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { 102 while (current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) {
102 out_configs->push_back(*current); 103 out_configs->push_back(*current);
103 out_configs->push_back(*(current + 1)); 104 out_configs->push_back(*(current + 1));
104 current += 2; 105 current += 2;
105 } 106 }
106 return true; 107 return true;
107 } 108 }
108 109
109 } // namespace ppapi 110 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698