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

Side by Side Diff: cc/layers/video_frame_provider_client_impl.cc

Issue 643583003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: foramted. Created 6 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cc/layers/video_frame_provider_client_impl.h" 5 #include "cc/layers/video_frame_provider_client_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/base/math_util.h" 8 #include "cc/base/math_util.h"
9 #include "cc/layers/video_layer_impl.h" 9 #include "cc/layers/video_layer_impl.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 // static 14 // static
15 scoped_refptr<VideoFrameProviderClientImpl> 15 scoped_refptr<VideoFrameProviderClientImpl>
16 VideoFrameProviderClientImpl::Create( 16 VideoFrameProviderClientImpl::Create(
17 VideoFrameProvider* provider) { 17 VideoFrameProvider* provider) {
18 return make_scoped_refptr( 18 return make_scoped_refptr(
19 new VideoFrameProviderClientImpl(provider)); 19 new VideoFrameProviderClientImpl(provider));
20 } 20 }
21 21
22 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() {} 22 VideoFrameProviderClientImpl::~VideoFrameProviderClientImpl() {}
23 23
24 VideoFrameProviderClientImpl::VideoFrameProviderClientImpl( 24 VideoFrameProviderClientImpl::VideoFrameProviderClientImpl(
25 VideoFrameProvider* provider) 25 VideoFrameProvider* provider)
26 : active_video_layer_(NULL), provider_(provider) { 26 : active_video_layer_(nullptr), provider_(provider) {
27 // This only happens during a commit on the compositor thread while the main 27 // This only happens during a commit on the compositor thread while the main
28 // thread is blocked. That makes this a thread-safe call to set the video 28 // thread is blocked. That makes this a thread-safe call to set the video
29 // frame provider client that does not require a lock. The same is true of 29 // frame provider client that does not require a lock. The same is true of
30 // the call to Stop(). 30 // the call to Stop().
31 provider_->SetVideoFrameProviderClient(this); 31 provider_->SetVideoFrameProviderClient(this);
32 32
33 // This matrix is the default transformation for stream textures, and flips 33 // This matrix is the default transformation for stream textures, and flips
34 // on the Y axis. 34 // on the Y axis.
35 stream_texture_matrix_ = gfx::Transform( 35 stream_texture_matrix_ = gfx::Transform(
36 1.0, 0.0, 0.0, 0.0, 36 1.0, 0.0, 0.0, 0.0,
37 0.0, -1.0, 0.0, 1.0, 37 0.0, -1.0, 0.0, 1.0,
38 0.0, 0.0, 1.0, 0.0, 38 0.0, 0.0, 1.0, 0.0,
39 0.0, 0.0, 0.0, 1.0); 39 0.0, 0.0, 0.0, 1.0);
40 } 40 }
41 41
42 void VideoFrameProviderClientImpl::Stop() { 42 void VideoFrameProviderClientImpl::Stop() {
43 if (!provider_) 43 if (!provider_)
44 return; 44 return;
45 provider_->SetVideoFrameProviderClient(NULL); 45 provider_->SetVideoFrameProviderClient(nullptr);
46 provider_ = NULL; 46 provider_ = nullptr;
47 } 47 }
48 48
49 scoped_refptr<media::VideoFrame> 49 scoped_refptr<media::VideoFrame>
50 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() { 50 VideoFrameProviderClientImpl::AcquireLockAndCurrentFrame() {
51 provider_lock_.Acquire(); // Balanced by call to ReleaseLock(). 51 provider_lock_.Acquire(); // Balanced by call to ReleaseLock().
52 if (!provider_) 52 if (!provider_)
53 return NULL; 53 return nullptr;
54 54
55 return provider_->GetCurrentFrame(); 55 return provider_->GetCurrentFrame();
56 } 56 }
57 57
58 void VideoFrameProviderClientImpl::PutCurrentFrame( 58 void VideoFrameProviderClientImpl::PutCurrentFrame(
59 const scoped_refptr<media::VideoFrame>& frame) { 59 const scoped_refptr<media::VideoFrame>& frame) {
60 provider_lock_.AssertAcquired(); 60 provider_lock_.AssertAcquired();
61 provider_->PutCurrentFrame(frame); 61 provider_->PutCurrentFrame(frame);
62 } 62 }
63 63
64 void VideoFrameProviderClientImpl::ReleaseLock() { 64 void VideoFrameProviderClientImpl::ReleaseLock() {
65 provider_lock_.AssertAcquired(); 65 provider_lock_.AssertAcquired();
66 provider_lock_.Release(); 66 provider_lock_.Release();
67 } 67 }
68 68
69 void VideoFrameProviderClientImpl::StopUsingProvider() { 69 void VideoFrameProviderClientImpl::StopUsingProvider() {
70 // Block the provider from shutting down until this client is done 70 // Block the provider from shutting down until this client is done
71 // using the frame. 71 // using the frame.
72 base::AutoLock locker(provider_lock_); 72 base::AutoLock locker(provider_lock_);
73 provider_ = NULL; 73 provider_ = nullptr;
74 } 74 }
75 75
76 void VideoFrameProviderClientImpl::DidReceiveFrame() { 76 void VideoFrameProviderClientImpl::DidReceiveFrame() {
77 TRACE_EVENT1("cc", 77 TRACE_EVENT1("cc",
78 "VideoFrameProviderClientImpl::DidReceiveFrame", 78 "VideoFrameProviderClientImpl::DidReceiveFrame",
79 "active_video_layer", 79 "active_video_layer",
80 !!active_video_layer_); 80 !!active_video_layer_);
81 if (active_video_layer_) 81 if (active_video_layer_)
82 active_video_layer_->SetNeedsRedraw(); 82 active_video_layer_->SetNeedsRedraw();
83 } 83 }
84 84
85 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) { 85 void VideoFrameProviderClientImpl::DidUpdateMatrix(const float* matrix) {
86 stream_texture_matrix_ = gfx::Transform( 86 stream_texture_matrix_ = gfx::Transform(
87 matrix[0], matrix[4], matrix[8], matrix[12], 87 matrix[0], matrix[4], matrix[8], matrix[12],
88 matrix[1], matrix[5], matrix[9], matrix[13], 88 matrix[1], matrix[5], matrix[9], matrix[13],
89 matrix[2], matrix[6], matrix[10], matrix[14], 89 matrix[2], matrix[6], matrix[10], matrix[14],
90 matrix[3], matrix[7], matrix[11], matrix[15]); 90 matrix[3], matrix[7], matrix[11], matrix[15]);
91 if (active_video_layer_) 91 if (active_video_layer_)
92 active_video_layer_->SetNeedsRedraw(); 92 active_video_layer_->SetNeedsRedraw();
93 } 93 }
94 94
95 } // namespace cc 95 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698