diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llmedia/llmediaimplexample2.cpp | 198 |
1 files changed, 0 insertions, 198 deletions
diff --git a/linden/indra/llmedia/llmediaimplexample2.cpp b/linden/indra/llmedia/llmediaimplexample2.cpp deleted file mode 100644 index 7590e19..0000000 --- a/linden/indra/llmedia/llmediaimplexample2.cpp +++ /dev/null | |||
@@ -1,198 +0,0 @@ | |||
1 | /** | ||
2 | * @file llmediaimplexample2.cpp | ||
3 | * @brief Example 2 of a media impl concrete class | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2009, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include "llmediaimplexample2.h" | ||
34 | #include "llmediaimplregister.h" | ||
35 | |||
36 | #include <cstring> | ||
37 | |||
38 | // register this impl with media manager factory | ||
39 | static LLMediaImplRegister sLLMediaImplExample2Reg( "LLMediaImplExample2", new LLMediaImplExample2Maker() ); | ||
40 | |||
41 | #include <iostream> | ||
42 | #include <time.h> | ||
43 | |||
44 | /////////////////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | LLMediaImplExample2Maker::LLMediaImplExample2Maker() | ||
47 | { | ||
48 | // Register to handle the scheme | ||
49 | mSchema.push_back( "example2." ); | ||
50 | } | ||
51 | |||
52 | /////////////////////////////////////////////////////////////////////////////// | ||
53 | // | ||
54 | LLMediaImplExample2::LLMediaImplExample2() : | ||
55 | mMediaPixels( 0 ) | ||
56 | { | ||
57 | setRequestedMediaSize( 500, 500 ); | ||
58 | setMediaDepth( 3 ); | ||
59 | |||
60 | mXpos = ( getMediaWidth() / 2 ) + rand() % ( getMediaWidth() / 16 ) - ( getMediaWidth() / 32 ); | ||
61 | mYpos = ( getMediaHeight() / 2 ) + rand() % ( getMediaHeight() / 16 ) - ( getMediaHeight() / 32 ); | ||
62 | |||
63 | srand( (unsigned int)(time( NULL )) ); | ||
64 | } | ||
65 | |||
66 | //////////////////////////////////////////////////////////////////////////////// | ||
67 | // (static) super-initialization - called once at application startup | ||
68 | bool LLMediaImplExample2::startup( LLMediaManagerData* init_data ) | ||
69 | { | ||
70 | return true; | ||
71 | } | ||
72 | |||
73 | //////////////////////////////////////////////////////////////////////////////// | ||
74 | // (static) super-uninitialization - called once at application closedown | ||
75 | bool LLMediaImplExample2::closedown() | ||
76 | { | ||
77 | return true; | ||
78 | } | ||
79 | |||
80 | //////////////////////////////////////////////////////////////////////////////// | ||
81 | // virtual | ||
82 | bool LLMediaImplExample2::init() | ||
83 | { | ||
84 | int buffer_size = getMediaBufferSize(); | ||
85 | |||
86 | mMediaPixels = new unsigned char[ buffer_size ]; | ||
87 | |||
88 | memset( mMediaPixels, 0x00, buffer_size ); | ||
89 | |||
90 | return true; | ||
91 | } | ||
92 | |||
93 | //////////////////////////////////////////////////////////////////////////////// | ||
94 | // virtual | ||
95 | bool LLMediaImplExample2::navigateTo( const std::string url ) | ||
96 | { | ||
97 | std::cout << "LLMediaImplExample2::navigateTo" << std::endl; | ||
98 | |||
99 | setStatus( LLMediaBase::STATUS_NAVIGATING ); | ||
100 | |||
101 | // force a size change event for new URL | ||
102 | LLMediaEvent event( this ); | ||
103 | mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event ); | ||
104 | |||
105 | return true; | ||
106 | } | ||
107 | |||
108 | //////////////////////////////////////////////////////////////////////////////// | ||
109 | // virtual | ||
110 | std::string LLMediaImplExample2::getVersion() | ||
111 | { | ||
112 | std::string version_string = "[" + sLLMediaImplExample2Reg.getImplName() + "] - " + "1.0.0.0"; | ||
113 | |||
114 | return version_string; | ||
115 | } | ||
116 | |||
117 | //////////////////////////////////////////////////////////////////////////////// | ||
118 | // virtual | ||
119 | bool LLMediaImplExample2::updateMedia() | ||
120 | { | ||
121 | if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED ) | ||
122 | { | ||
123 | static int x_inc = rand() % 5 + 2; | ||
124 | static int y_inc = rand() % 5 + 2; | ||
125 | int block_size = 32; | ||
126 | |||
127 | for( int y = 0; y < block_size; ++y ) | ||
128 | { | ||
129 | for( int x = 0; x < block_size; ++x ) | ||
130 | { | ||
131 | int rowspan = getMediaWidth() * getMediaDepth(); | ||
132 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = 0; | ||
133 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = 0; | ||
134 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = 0; | ||
135 | }; | ||
136 | }; | ||
137 | |||
138 | if ( mXpos + x_inc < 0 || mXpos + x_inc >= getMediaWidth() - block_size ) | ||
139 | x_inc =- x_inc; | ||
140 | |||
141 | if ( mYpos + y_inc < 0 || mYpos + y_inc >= getMediaHeight() - block_size ) | ||
142 | y_inc =- y_inc; | ||
143 | |||
144 | mXpos += x_inc; | ||
145 | mYpos += y_inc; | ||
146 | |||
147 | unsigned char col_r = rand() % 0xff; | ||
148 | unsigned char col_g = rand() % 0xff; | ||
149 | unsigned char col_b = rand() % 0xff; | ||
150 | |||
151 | for( int y = 0; y < block_size; ++y ) | ||
152 | { | ||
153 | for( int x = 0; x < block_size; ++x ) | ||
154 | { | ||
155 | int rowspan = getMediaWidth() * getMediaDepth(); | ||
156 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = col_r; | ||
157 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = col_g; | ||
158 | mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = col_b; | ||
159 | }; | ||
160 | }; | ||
161 | |||
162 | // emit an event to say that something in the media stream changed | ||
163 | LLMediaEvent event( this ); | ||
164 | mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event ); | ||
165 | }; | ||
166 | |||
167 | // update the command (e.g. transport controls) state | ||
168 | updateCommand(); | ||
169 | |||
170 | return false; | ||
171 | } | ||
172 | |||
173 | //////////////////////////////////////////////////////////////////////////////// | ||
174 | // virtual | ||
175 | unsigned char* LLMediaImplExample2::getMediaData() | ||
176 | { | ||
177 | return mMediaPixels; | ||
178 | } | ||
179 | |||
180 | //////////////////////////////////////////////////////////////////////////////// | ||
181 | // virtual | ||
182 | bool LLMediaImplExample2::reset() | ||
183 | { | ||
184 | if ( mMediaPixels ) | ||
185 | { | ||
186 | delete [] mMediaPixels; | ||
187 | }; | ||
188 | |||
189 | return true; | ||
190 | } | ||
191 | |||
192 | //////////////////////////////////////////////////////////////////////////////// | ||
193 | // virtual | ||
194 | bool LLMediaImplExample2::setRequestedMediaSize( int width, int height ) | ||
195 | { | ||
196 | // we accept any size: | ||
197 | return setMediaSize(width, height); | ||
198 | } | ||