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 } | 20 } |
21 | 21 |
22 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared( | 22 PPB_VideoDecoder_Shared::PPB_VideoDecoder_Shared( |
23 const HostResource& host_resource) | 23 const HostResource& host_resource) |
24 : Resource(OBJECT_IS_PROXY, host_resource), | 24 : Resource(OBJECT_IS_PROXY, host_resource), |
25 graphics_context_(0), | 25 graphics_context_(0), |
26 gles2_impl_(NULL) { | 26 gles2_impl_(NULL) { |
27 } | 27 } |
28 | 28 |
29 PPB_VideoDecoder_Shared::~PPB_VideoDecoder_Shared() { | 29 PPB_VideoDecoder_Shared::~PPB_VideoDecoder_Shared() { |
| 30 // Destroy() must be called before the object is destroyed. |
| 31 DCHECK(graphics_context_ == 0); |
30 } | 32 } |
31 | 33 |
32 thunk::PPB_VideoDecoder_API* PPB_VideoDecoder_Shared::AsPPB_VideoDecoder_API() { | 34 thunk::PPB_VideoDecoder_API* PPB_VideoDecoder_Shared::AsPPB_VideoDecoder_API() { |
33 return this; | 35 return this; |
34 } | 36 } |
35 | 37 |
36 void PPB_VideoDecoder_Shared::InitCommon( | 38 void PPB_VideoDecoder_Shared::InitCommon( |
37 PP_Resource graphics_context, | 39 PP_Resource graphics_context, |
38 gpu::gles2::GLES2Implementation* gles2_impl) { | 40 gpu::gles2::GLES2Implementation* gles2_impl) { |
39 DCHECK(graphics_context); | 41 DCHECK(graphics_context); |
40 DCHECK(!gles2_impl_ && !graphics_context_); | 42 DCHECK(!gles2_impl_ && !graphics_context_); |
41 gles2_impl_ = gles2_impl; | 43 gles2_impl_ = gles2_impl; |
42 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context); | 44 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(graphics_context); |
43 graphics_context_ = graphics_context; | 45 graphics_context_ = graphics_context; |
44 } | 46 } |
45 | 47 |
46 void PPB_VideoDecoder_Shared::Destroy() { | 48 void PPB_VideoDecoder_Shared::Destroy() { |
47 graphics_context_ = 0; | 49 if (graphics_context_) { |
| 50 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource( |
| 51 graphics_context_); |
| 52 graphics_context_ = 0; |
| 53 } |
48 gles2_impl_ = NULL; | 54 gles2_impl_ = NULL; |
49 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(graphics_context_); | |
50 } | 55 } |
51 | 56 |
52 bool PPB_VideoDecoder_Shared::SetFlushCallback( | 57 bool PPB_VideoDecoder_Shared::SetFlushCallback( |
53 scoped_refptr<TrackedCallback> callback) { | 58 scoped_refptr<TrackedCallback> callback) { |
54 if (TrackedCallback::IsPending(flush_callback_)) | 59 if (TrackedCallback::IsPending(flush_callback_)) |
55 return false; | 60 return false; |
56 flush_callback_ = callback; | 61 flush_callback_ = callback; |
57 return true; | 62 return true; |
58 } | 63 } |
59 | 64 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 graphics_context_, false); | 102 graphics_context_, false); |
98 DCHECK(enter_g3d.succeeded()); | 103 DCHECK(enter_g3d.succeeded()); |
99 PPB_Graphics3D_Shared* graphics3d = | 104 PPB_Graphics3D_Shared* graphics3d = |
100 static_cast<PPB_Graphics3D_Shared*>(enter_g3d.object()); | 105 static_cast<PPB_Graphics3D_Shared*>(enter_g3d.object()); |
101 PPB_Graphics3D_Shared::ScopedNoLocking dont_lock(graphics3d); | 106 PPB_Graphics3D_Shared::ScopedNoLocking dont_lock(graphics3d); |
102 gles2_impl_->Flush(); | 107 gles2_impl_->Flush(); |
103 } | 108 } |
104 } | 109 } |
105 | 110 |
106 } // namespace ppapi | 111 } // namespace ppapi |
OLD | NEW |