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

Side by Side Diff: webkit/glue/webkitclient_impl.cc

Issue 6265009: Bundle audio spatialization resources for use by the web audio API... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/webkitclient_impl.h" 5 #include "webkit/glue/webkitclient_impl.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <malloc.h> 8 #include <malloc.h>
9 #endif 9 #endif
10 10
11 #include <math.h> 11 #include <math.h>
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
16 #include "base/lock.h" 16 #include "base/lock.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/metrics/stats_counters.h" 18 #include "base/metrics/stats_counters.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/process_util.h" 20 #include "base/process_util.h"
21 #include "base/platform_file.h" 21 #include "base/platform_file.h"
22 #include "base/singleton.h" 22 #include "base/singleton.h"
23 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
24 #include "base/string_util.h" 24 #include "base/string_util.h"
25 #include "base/time.h" 25 #include "base/time.h"
26 #include "base/utf_string_conversions.h" 26 #include "base/utf_string_conversions.h"
27 #include "grit/webkit_chromium_audio_resources.h"
27 #include "grit/webkit_resources.h" 28 #include "grit/webkit_resources.h"
28 #include "grit/webkit_strings.h" 29 #include "grit/webkit_strings.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginListBuilder. h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginListBuilder. h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 void WebKitClientImpl::traceEventBegin(const char* name, void* id, 285 void WebKitClientImpl::traceEventBegin(const char* name, void* id,
285 const char* extra) { 286 const char* extra) {
286 TRACE_EVENT_BEGIN(name, id, extra); 287 TRACE_EVENT_BEGIN(name, id, extra);
287 } 288 }
288 289
289 void WebKitClientImpl::traceEventEnd(const char* name, void* id, 290 void WebKitClientImpl::traceEventEnd(const char* name, void* id,
290 const char* extra) { 291 const char* extra) {
291 TRACE_EVENT_END(name, id, extra); 292 TRACE_EVENT_END(name, id, extra);
292 } 293 }
293 294
295 namespace {
296
297 WebData loadAudioSpatializationResource(const char* name) {
298 const size_t kExpectedSpatializationNameLength = 31;
299 if (strlen(name) != kExpectedSpatializationNameLength) {
300 return WebData();
301 }
302
303 // Extract the azimuth and elevation from the resource name.
304 int azimuth = 0;
305 int elevation = 0;
306 sscanf(name, "IRC_Composite_C_R0195_T%3d_P%3d", &azimuth, &elevation);
tony 2011/01/19 17:46:10 Nit: Maybe you could also check the return value o
307
308 // The resource index values go through the elevations first, then azimuths.
309 const int kAngleSpacing = 15;
310
311 // 0 <= elevation <= 90 (or 315 <= elevation <= 345)
312 // in increments of 15 degrees.
313 int elevation_index =
314 elevation <= 90 ? elevation / kAngleSpacing :
315 7 + (elevation - 315) / kAngleSpacing;
316 bool is_elevation_index_good = 0 <= elevation_index < 10;
tony 2011/01/19 17:46:10 I don't think this does what you think this does.
317
318 // 0 <= azimuth < 360 in increments of 15 degrees.
319 int azimuth_index = azimuth / kAngleSpacing;
320 bool is_azimuth_index_good = 0 <= azimuth_index < 24;
tony 2011/01/19 17:46:10 Same as above, I think you need to split this out
321
322 const int kNumberOfElevations = 10;
323 const int kNumberOfAudioResources = 240;
324 int resource_index = kNumberOfElevations * azimuth_index + elevation_index;
325 bool is_resource_index_good = 0 <= resource_index < kNumberOfAudioResources;
tony 2011/01/19 17:46:10 Same error as above.
326
327 if (is_azimuth_index_good && is_elevation_index_good &&
328 is_resource_index_good) {
329 const int kFirstAudioResourceIndex = IDR_AUDIO_SPATIALIZATION_T000_P000;
330 base::StringPiece resource =
331 GetDataResource(kFirstAudioResourceIndex + resource_index);
332 return WebData(resource.data(), resource.size());
333 }
334
335 NOTREACHED();
336 return WebData();
337 }
338
339 } // namespace
340
294 WebData WebKitClientImpl::loadResource(const char* name) { 341 WebData WebKitClientImpl::loadResource(const char* name) {
295 struct { 342 struct {
296 const char* name; 343 const char* name;
297 int id; 344 int id;
298 } resources[] = { 345 } resources[] = {
299 { "missingImage", IDR_BROKENIMAGE }, 346 { "missingImage", IDR_BROKENIMAGE },
300 { "mediaPause", IDR_MEDIA_PAUSE_BUTTON }, 347 { "mediaPause", IDR_MEDIA_PAUSE_BUTTON },
301 { "mediaPlay", IDR_MEDIA_PLAY_BUTTON }, 348 { "mediaPlay", IDR_MEDIA_PLAY_BUTTON },
302 { "mediaPlayDisabled", IDR_MEDIA_PLAY_BUTTON_DISABLED }, 349 { "mediaPlayDisabled", IDR_MEDIA_PLAY_BUTTON_DISABLED },
303 { "mediaSoundDisabled", IDR_MEDIA_SOUND_DISABLED }, 350 { "mediaSoundDisabled", IDR_MEDIA_SOUND_DISABLED },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 { "linuxRadioDisabledOff", IDR_LINUX_RADIO_DISABLED_OFF }, 382 { "linuxRadioDisabledOff", IDR_LINUX_RADIO_DISABLED_OFF },
336 { "linuxRadioDisabledOn", IDR_LINUX_RADIO_DISABLED_ON }, 383 { "linuxRadioDisabledOn", IDR_LINUX_RADIO_DISABLED_ON },
337 { "linuxRadioOff", IDR_LINUX_RADIO_OFF }, 384 { "linuxRadioOff", IDR_LINUX_RADIO_OFF },
338 { "linuxRadioOn", IDR_LINUX_RADIO_ON }, 385 { "linuxRadioOn", IDR_LINUX_RADIO_ON },
339 { "linuxProgressBar", IDR_PROGRESS_BAR }, 386 { "linuxProgressBar", IDR_PROGRESS_BAR },
340 { "linuxProgressBorderLeft", IDR_PROGRESS_BORDER_LEFT }, 387 { "linuxProgressBorderLeft", IDR_PROGRESS_BORDER_LEFT },
341 { "linuxProgressBorderRight", IDR_PROGRESS_BORDER_RIGHT }, 388 { "linuxProgressBorderRight", IDR_PROGRESS_BORDER_RIGHT },
342 { "linuxProgressValue", IDR_PROGRESS_VALUE }, 389 { "linuxProgressValue", IDR_PROGRESS_VALUE },
343 #endif 390 #endif
344 }; 391 };
345 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { 392
346 if (!strcmp(name, resources[i].name)) { 393 // Check the name prefix to see if it's an audio resource.
347 base::StringPiece resource = GetDataResource(resources[i].id); 394 if (!strncmp(name, "IRC_Composite", 13)) {
tony 2011/01/19 17:46:10 There's a StartsWithASCII() function in base/strin
348 return WebData(resource.data(), resource.size()); 395 return loadAudioSpatializationResource(name);
396 } else {
397 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
398 if (!strcmp(name, resources[i].name)) {
399 base::StringPiece resource = GetDataResource(resources[i].id);
400 return WebData(resource.data(), resource.size());
401 }
349 } 402 }
350 } 403 }
351 // TODO(jhawkins): Restore this NOTREACHED once WK stops sending in empty 404 // TODO(jhawkins): Restore this NOTREACHED once WK stops sending in empty
352 // strings. http://crbug.com/50675. 405 // strings. http://crbug.com/50675.
353 //NOTREACHED() << "Unknown image resource " << name; 406 //NOTREACHED() << "Unknown image resource " << name;
354 return WebData(); 407 return WebData();
355 } 408 }
356 409
357 bool WebKitClientImpl::loadAudioResource( 410 bool WebKitClientImpl::loadAudioResource(
358 WebKit::WebAudioBus* destination_bus, const char* audio_file_data, 411 WebKit::WebAudioBus* destination_bus, const char* audio_file_data,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ++shared_timer_suspended_; 592 ++shared_timer_suspended_;
540 } 593 }
541 594
542 void WebKitClientImpl::ResumeSharedTimer() { 595 void WebKitClientImpl::ResumeSharedTimer() {
543 // The shared timer may have fired or been adjusted while we were suspended. 596 // The shared timer may have fired or been adjusted while we were suspended.
544 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) 597 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning())
545 setSharedTimerFireTime(shared_timer_fire_time_); 598 setSharedTimerFireTime(shared_timer_fire_time_);
546 } 599 }
547 600
548 } // namespace webkit_glue 601 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698