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

Side by Side Diff: talk/app/webrtc/java/jni/native_handle_impl.cc

Issue 1487493002: Add helper KeepRefUntilDone (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changed back to use template Created 5 years 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
« no previous file with comments | « no previous file | webrtc/base/callback_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 10 matching lines...) Expand all
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #include "talk/app/webrtc/java/jni/native_handle_impl.h" 28 #include "talk/app/webrtc/java/jni/native_handle_impl.h"
29 29
30 #include "webrtc/base/checks.h" 30 #include "webrtc/base/checks.h"
31 #include "webrtc/base/bind.h" 31 #include "webrtc/base/keep_ref_until_done.h"
32 #include "webrtc/base/scoped_ref_ptr.h"
32 33
33 using rtc::scoped_refptr;
34 using webrtc::NativeHandleBuffer; 34 using webrtc::NativeHandleBuffer;
35 35
36 namespace webrtc_jni { 36 namespace webrtc_jni {
37 37
38 namespace {
39 void ScaledFrameNotInUse(scoped_refptr<NativeHandleBuffer> original) {}
40 } // anonymous namespace
41
42 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni, 38 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni,
43 jint j_oes_texture_id, 39 jint j_oes_texture_id,
44 jfloatArray j_transform_matrix) 40 jfloatArray j_transform_matrix)
45 : oes_texture_id(j_oes_texture_id) { 41 : oes_texture_id(j_oes_texture_id) {
46 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix)); 42 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix));
47 jfloat* transform_matrix_ptr = 43 jfloat* transform_matrix_ptr =
48 jni->GetFloatArrayElements(j_transform_matrix, nullptr); 44 jni->GetFloatArrayElements(j_transform_matrix, nullptr);
49 for (int i = 0; i < 16; ++i) { 45 for (int i = 0; i < 16; ++i) {
50 sampling_matrix[i] = transform_matrix_ptr[i]; 46 sampling_matrix[i] = transform_matrix_ptr[i];
51 } 47 }
(...skipping 28 matching lines...) Expand all
80 // TODO(perkj) Implement cropping. 76 // TODO(perkj) Implement cropping.
81 RTC_CHECK_EQ(cropped_input_width, width_); 77 RTC_CHECK_EQ(cropped_input_width, width_);
82 RTC_CHECK_EQ(cropped_input_height, height_); 78 RTC_CHECK_EQ(cropped_input_height, height_);
83 79
84 // Here we use Bind magic to add a reference count to |this| until the newly 80 // Here we use Bind magic to add a reference count to |this| until the newly
85 // created AndroidTextureBuffer is destructed. ScaledFrameNotInUse will be 81 // created AndroidTextureBuffer is destructed. ScaledFrameNotInUse will be
86 // called that happens and when it finishes, the reference count to |this| 82 // called that happens and when it finishes, the reference count to |this|
87 // will be decreased by one. 83 // will be decreased by one.
88 return new rtc::RefCountedObject<AndroidTextureBuffer>( 84 return new rtc::RefCountedObject<AndroidTextureBuffer>(
89 dst_widht, dst_height, native_handle_, 85 dst_widht, dst_height, native_handle_,
90 rtc::Bind(&ScaledFrameNotInUse, this)); 86 rtc::KeepRefUntilDone(this));
91 } 87 }
92 88
93 } // namespace webrtc_jni 89 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/callback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698