1 /* 2 * Copyright (C) 2007, 2008, 2009, 2010 Apple, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 #include "config.h" 26 27 #include "QTTrack.h" 28 29 #include <Movies.h> 30 #include <QTML.h> 31 32 using namespace std; 33 34 class QTTrackPrivate { 35 WTF_MAKE_NONCOPYABLE(QTTrackPrivate); 36 public: 37 QTTrackPrivate(); 38 ~QTTrackPrivate(); 39 40 QTTrack* m_track; 41 Track m_trackHandle; 42 }; 43 44 QTTrackPrivate::QTTrackPrivate() 45 : m_track(0) 46 , m_trackHandle(0) 47 { 48 } 49 50 QTTrackPrivate::~QTTrackPrivate() 51 { 52 m_trackHandle = 0; 53 } 54 55 PassRefPtr<QTTrack> QTTrack::create(Track trackHandle) 56 { 57 return adoptRef(new QTTrack(trackHandle)); 58 } 59 60 QTTrack::QTTrack(Track trackHandle) 61 : m_private(new QTTrackPrivate()) 62 { 63 m_private->m_track = this; 64 m_private->m_trackHandle = trackHandle; 65 } 66 67 QTTrack::~QTTrack() 68 { 69 delete m_private; 70 } 71 72 bool QTTrack::isEnabled() const 73 { 74 ASSERT(m_private->m_track); 75 return GetTrackEnabled(m_private->m_trackHandle); 76 } 77 78 void QTTrack::setEnabled(bool enabled) 79 { 80 ASSERT(m_private->m_trackHandle); 81 SetTrackEnabled(m_private->m_trackHandle, enabled); 82 } 83 84 CGAffineTransform QTTrack::getTransform() const 85 { 86 ASSERT(m_private->m_trackHandle); 87 MatrixRecord m = {0}; 88 GetTrackMatrix(m_private->m_trackHandle, &m); 89 90 ASSERT(!m.matrix[0][2]); 91 ASSERT(!m.matrix[1][2]); 92 CGAffineTransform transform = CGAffineTransformMake( 93 Fix2X(m.matrix[0][0]), 94 Fix2X(m.matrix[0][1]), 95 Fix2X(m.matrix[1][0]), 96 Fix2X(m.matrix[1][1]), 97 Fix2X(m.matrix[2][0]), 98 Fix2X(m.matrix[2][1])); 99 100 return transform; 101 } 102 103 void QTTrack::setTransform(CGAffineTransform t) 104 { 105 ASSERT(m_private->m_trackHandle); 106 MatrixRecord m = {{ 107 {X2Fix(t.a), X2Fix(t.b), 0}, 108 {X2Fix(t.c), X2Fix(t.d), 0}, 109 {X2Fix(t.tx), X2Fix(t.ty), fract1}, 110 }}; 111 112 SetTrackMatrix(m_private->m_trackHandle, &m); 113 } 114 115 void QTTrack::resetTransform() 116 { 117 ASSERT(m_private->m_trackHandle); 118 SetTrackMatrix(m_private->m_trackHandle, 0); 119 } 120 121