OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppb_video_decoder_shared.h" | 5 #include "ppapi/shared_impl/ppb_video_decoder_shared.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/shared_impl/ppb_graphics_3d_shared.h" | 10 #include "ppapi/shared_impl/ppb_graphics_3d_shared.h" |
11 #include "ppapi/shared_impl/resource_tracker.h" | 11 #include "ppapi/shared_impl/resource_tracker.h" |
12 #include "ppapi/thunk/enter.h" | 12 #include "ppapi/thunk/enter.h" |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 | 15 |
16 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared(PP_Instance instance) | 16 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared(PP_Instance instance) |
17 : Resource(OBJECT_IS_IMPL, instance), | 17 : Resource(OBJECT_IS_IMPL, instance), |
18 graphics_context_(0), | 18 graphics_context_(0), |
19 gles2_impl_(NULL) { | 19 gles2_impl_(NULL) {} |
20 } | |
21 | 20 |
22 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared( | 21 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared( |
23 const HostResource& host_resource) | 22 const HostResource& host_resource) |
24 : Resource(OBJECT_IS_PROXY, host_resource), | 23 : Resource(OBJECT_IS_PROXY, host_resource), |
25 graphics_context_(0), | 24 graphics_context_(0), |
26 gles2_impl_(NULL) { | 25 gles2_impl_(NULL) {} |
27 } | |
28 | 26 |
29 PPB_VideoDecoder_Shared::~PPB_VideoDecoder_Shared() { | 27 PPB_VideoDecoder_Shared::~PPB_VideoDecoder_Shared() { |
30 // Destroy() must be called before the object is destroyed. | 28 // Destroy() must be called before the object is destroyed. |
31 DCHECK(graphics_context_ == 0); | 29 DCHECK(graphics_context_ == 0); |
32 } | 30 } |
33 | 31 |
34 thunk::PPB_VideoDecoder_API* PPB_VideoDecoder_Shared::AsPPB_VideoDecoder_API() { | 32 thunk::PPB_VideoDecoder_API* PPB_VideoDecoder_Shared::AsPPB_VideoDecoder_API() { |
35 return this; | 33 return this; |
36 } | 34 } |
37 | 35 |
(...skipping 28 matching lines...) Expand all Loading... |
66 scoped_refptr<TrackedCallback> callback) { | 64 scoped_refptr<TrackedCallback> callback) { |
67 if (TrackedCallback::IsPending(reset_callback_)) | 65 if (TrackedCallback::IsPending(reset_callback_)) |
68 return false; | 66 return false; |
69 reset_callback_ = callback; | 67 reset_callback_ = callback; |
70 return true; | 68 return true; |
71 } | 69 } |
72 | 70 |
73 bool PPB_VideoDecoder_Shared::SetBitstreamBufferCallback( | 71 bool PPB_VideoDecoder_Shared::SetBitstreamBufferCallback( |
74 int32 bitstream_buffer_id, | 72 int32 bitstream_buffer_id, |
75 scoped_refptr<TrackedCallback> callback) { | 73 scoped_refptr<TrackedCallback> callback) { |
76 return bitstream_buffer_callbacks_.insert( | 74 return bitstream_buffer_callbacks_.insert(std::make_pair(bitstream_buffer_id, |
77 std::make_pair(bitstream_buffer_id, callback)).second; | 75 callback)).second; |
78 } | 76 } |
79 | 77 |
80 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) { | 78 void PPB_VideoDecoder_Shared::RunFlushCallback(int32 result) { |
81 flush_callback_->Run(result); | 79 flush_callback_->Run(result); |
82 } | 80 } |
83 | 81 |
84 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) { | 82 void PPB_VideoDecoder_Shared::RunResetCallback(int32 result) { |
85 reset_callback_->Run(result); | 83 reset_callback_->Run(result); |
86 } | 84 } |
87 | 85 |
88 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback( | 86 void PPB_VideoDecoder_Shared::RunBitstreamBufferCallback( |
89 int32 bitstream_buffer_id, int32 result) { | 87 int32 bitstream_buffer_id, |
| 88 int32 result) { |
90 CallbackById::iterator it = | 89 CallbackById::iterator it = |
91 bitstream_buffer_callbacks_.find(bitstream_buffer_id); | 90 bitstream_buffer_callbacks_.find(bitstream_buffer_id); |
92 DCHECK(it != bitstream_buffer_callbacks_.end()); | 91 DCHECK(it != bitstream_buffer_callbacks_.end()); |
93 scoped_refptr<TrackedCallback> cc = it->second; | 92 scoped_refptr<TrackedCallback> cc = it->second; |
94 bitstream_buffer_callbacks_.erase(it); | 93 bitstream_buffer_callbacks_.erase(it); |
95 cc->Run(PP_OK); | 94 cc->Run(PP_OK); |
96 } | 95 } |
97 | 96 |
98 void PPB_VideoDecoder_Shared::FlushCommandBuffer() { | 97 void PPB_VideoDecoder_Shared::FlushCommandBuffer() { |
99 // Ensure that graphics_context is still live before using gles2_impl_. | 98 // Ensure that graphics_context is still live before using gles2_impl_. |
100 // Our "plugin reference" is not enough to keep graphics_context alive if | 99 // Our "plugin reference" is not enough to keep graphics_context alive if |
101 // DidDeleteInstance() has been called. | 100 // DidDeleteInstance() has been called. |
102 if (PpapiGlobals::Get()->GetResourceTracker()->GetResource( | 101 if (PpapiGlobals::Get()->GetResourceTracker()->GetResource( |
103 graphics_context_)) { | 102 graphics_context_)) { |
104 if (gles2_impl_) | 103 if (gles2_impl_) |
105 gles2_impl_->Flush(); | 104 gles2_impl_->Flush(); |
106 } | 105 } |
107 } | 106 } |
108 | 107 |
109 } // namespace ppapi | 108 } // namespace ppapi |
OLD | NEW |