OLD | NEW |
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/shared_impl/resource_tracker.h" |
12 #include "ppapi/thunk/ppb_context_3d_api.h" | 12 #include "ppapi/thunk/ppb_context_3d_api.h" |
13 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
14 | 14 |
15 using ppapi::thunk::PPB_Context3D_API; | 15 using ppapi::thunk::PPB_Context3D_API; |
16 | 16 |
17 namespace ppapi { | 17 namespace ppapi { |
18 | 18 |
19 VideoDecoderImpl::VideoDecoderImpl() | 19 VideoDecoderImpl::VideoDecoderImpl() |
20 : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)), | 20 : flush_callback_(PP_MakeCompletionCallback(NULL, NULL)), |
21 reset_callback_(PP_MakeCompletionCallback(NULL, NULL)), | 21 reset_callback_(PP_MakeCompletionCallback(NULL, NULL)), |
22 context3d_id_(0), | 22 graphics_context_(0), |
23 gles2_impl_(NULL) { | 23 gles2_impl_(NULL) { |
24 } | 24 } |
25 | 25 |
26 VideoDecoderImpl::~VideoDecoderImpl() { | 26 VideoDecoderImpl::~VideoDecoderImpl() { |
27 } | 27 } |
28 | 28 |
29 bool VideoDecoderImpl::Init(PP_Resource context3d_id, | 29 void VideoDecoderImpl::InitCommon( |
30 PPB_Context3D_API* context3d, | 30 PP_Resource graphics_context, |
31 const PP_VideoConfigElement* decoder_config) { | 31 gpu::gles2::GLES2Implementation* gles2_impl) { |
32 if (!context3d || !decoder_config || !context3d_id) | 32 DCHECK(graphics_context); |
33 return false; | 33 DCHECK(!gles2_impl_ && !graphics_context_); |
34 | 34 gles2_impl_ = gles2_impl; |
35 DCHECK(!gles2_impl_ && !context3d_id_); | 35 TrackerBase::Get()->GetResourceTracker()->AddRefResource(graphics_context); |
36 gles2_impl_ = context3d->GetGLES2Impl(); | 36 graphics_context_ = graphics_context; |
37 TrackerBase::Get()->GetResourceTracker()->AddRefResource(context3d_id); | |
38 context3d_id_ = context3d_id; | |
39 return true; | |
40 } | 37 } |
41 | 38 |
42 void VideoDecoderImpl::Destroy() { | 39 void VideoDecoderImpl::Destroy() { |
43 context3d_id_ = 0; | 40 graphics_context_ = 0; |
44 gles2_impl_ = NULL; | 41 gles2_impl_ = NULL; |
45 TrackerBase::Get()->GetResourceTracker()->ReleaseResource(context3d_id_); | 42 TrackerBase::Get()->GetResourceTracker()->ReleaseResource(graphics_context_); |
46 } | 43 } |
47 | 44 |
48 bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) { | 45 bool VideoDecoderImpl::SetFlushCallback(PP_CompletionCallback callback) { |
49 CHECK(callback.func); | 46 CHECK(callback.func); |
50 if (flush_callback_.func) | 47 if (flush_callback_.func) |
51 return false; | 48 return false; |
52 flush_callback_ = callback; | 49 flush_callback_ = callback; |
53 return true; | 50 return true; |
54 } | 51 } |
55 | 52 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 const PP_VideoConfigElement* current = configs_to_copy; | 98 const PP_VideoConfigElement* current = configs_to_copy; |
102 while (current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { | 99 while (current && *current != PP_VIDEOATTR_DICTIONARY_TERMINATOR) { |
103 out_configs->push_back(*current); | 100 out_configs->push_back(*current); |
104 out_configs->push_back(*(current + 1)); | 101 out_configs->push_back(*(current + 1)); |
105 current += 2; | 102 current += 2; |
106 } | 103 } |
107 return true; | 104 return true; |
108 } | 105 } |
109 | 106 |
110 } // namespace ppapi | 107 } // namespace ppapi |
OLD | NEW |