Import Cobalt 13.103164 Change-Id: Ie7a04d9db584bed593c82cb8ea5aba86721920b2
diff --git a/src/cobalt/base/wrap_main_starboard.h b/src/cobalt/base/wrap_main_starboard.h index aa57397..15ababb 100644 --- a/src/cobalt/base/wrap_main_starboard.h +++ b/src/cobalt/base/wrap_main_starboard.h
@@ -36,7 +36,7 @@ static MessageLoopForUI* g_loop = NULL; static bool g_started = false; switch (event->type) { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypePreload: { SbEventStartData* data = static_cast<SbEventStartData*>(event->data); @@ -55,7 +55,7 @@ g_started = true; break; } -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 case kSbEventTypeStart: { SbEventStartData* data = static_cast<SbEventStartData*>(event->data);
diff --git a/src/cobalt/bindings/v8c/__init__.py b/src/cobalt/bindings/v8c/__init__.py new file mode 100644 index 0000000..ef65bee --- /dev/null +++ b/src/cobalt/bindings/v8c/__init__.py
@@ -0,0 +1 @@ +# Required for Python to search this directory for module files
diff --git a/src/cobalt/bindings/v8c/bootstrap_path.py b/src/cobalt/bindings/v8c/bootstrap_path.py new file mode 100644 index 0000000..69a1b65 --- /dev/null +++ b/src/cobalt/bindings/v8c/bootstrap_path.py
@@ -0,0 +1,49 @@ +# +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +"""Utility to prepend the top-level source directory to sys.path. + +Since this may be used outside of gclient or git environment (such as part of a +tarball), the path to the root must be hardcoded. +""" + +import os +import sys + + +def _GetSrcRoot(): + """Finds the first directory named 'src' that this module is in.""" + current_path = os.path.normpath(__file__) + while os.path.basename(current_path) != 'src': + next_path = os.path.dirname(current_path) + if next_path == current_path: + raise RuntimeError('Could not find src directory.') + current_path = next_path + return os.path.abspath(current_path) + + +sys.path.insert(0, _GetSrcRoot()) + +# Add blink's python tools to the path. + +sys.path.append( + os.path.normpath( + os.path.join(_GetSrcRoot(), 'third_party', 'blink', 'Tools', + 'Scripts'))) + +sys.path.append( + os.path.normpath( + os.path.join(_GetSrcRoot(), 'third_party', 'blink', 'Source', + 'bindings', 'scripts')))
diff --git a/src/cobalt/bindings/v8c/code_generator_v8c.py b/src/cobalt/bindings/v8c/code_generator_v8c.py new file mode 100644 index 0000000..ca927f3 --- /dev/null +++ b/src/cobalt/bindings/v8c/code_generator_v8c.py
@@ -0,0 +1,61 @@ +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""V8c-specific implementation of CodeGeneratorCobalt. + +Defines CodeGeneratorV8c and ExpressionGeneratorV8c classes. +""" + +import os + +from cobalt.bindings.code_generator_cobalt import CodeGeneratorCobalt +from cobalt.bindings.expression_generator import ExpressionGenerator + + +class ExpressionGeneratorV8c(ExpressionGenerator): + """Implementation of ExpressionGenerator for V8.""" + + def is_undefined(self, arg): + # TODO: Implement. + return '' + + def is_undefined_or_null(self, arg): + # TODO: Implement. + return '' + + def inherits_interface(self, interface_name, arg): + # TODO: Implement. + return '' + + def is_number(self, arg): + # TODO: Implement. + return '' + + +class CodeGeneratorV8c(CodeGeneratorCobalt): + """Code generator class for V8 bindings.""" + + _expression_generator = ExpressionGeneratorV8c() + + def __init__(self, *args, **kwargs): + module_path, _ = os.path.split(os.path.realpath(__file__)) + templates_dir = os.path.normpath(os.path.join(module_path, 'templates')) + super(CodeGeneratorV8c, self).__init__(templates_dir, *args, **kwargs) + + @property + def generated_file_prefix(self): + return 'v8c' + + @property + def expression_generator(self): + return CodeGeneratorV8c._expression_generator
diff --git a/src/cobalt/bindings/v8c/generate_conversion_header_v8c.py b/src/cobalt/bindings/v8c/generate_conversion_header_v8c.py new file mode 100644 index 0000000..8901cc2 --- /dev/null +++ b/src/cobalt/bindings/v8c/generate_conversion_header_v8c.py
@@ -0,0 +1,24 @@ +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Generate a conversion header for SpiderMonkey.""" + +import sys + +import bootstrap_path # pylint: disable=g-bad-import-order,unused-import + +from cobalt.bindings.generate_conversion_header import generate_header +from cobalt.bindings.v8c.code_generator_v8c import CodeGeneratorV8c + +if __name__ == '__main__': + sys.exit(generate_header(CodeGeneratorV8c))
diff --git a/src/cobalt/bindings/v8c/idl_compiler_v8c.py b/src/cobalt/bindings/v8c/idl_compiler_v8c.py new file mode 100644 index 0000000..6c8c92e --- /dev/null +++ b/src/cobalt/bindings/v8c/idl_compiler_v8c.py
@@ -0,0 +1,28 @@ +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Compile an .idl file to Cobalt v8c bindings (.h and .cpp files). + +Calls into idl_compiler_cobalt.shared_main specifying the V8 +CodeGenerator class. +""" + +import sys + +import bootstrap_path # pylint: disable=unused-import + +from cobalt.bindings.idl_compiler_cobalt import generate_bindings +from cobalt.bindings.v8c.code_generator_v8c import CodeGeneratorV8c + +if __name__ == '__main__': + sys.exit(generate_bindings(CodeGeneratorV8c))
diff --git a/src/cobalt/bindings/v8c/templates/callback-interface.cc.template b/src/cobalt/bindings/v8c/templates/callback-interface.cc.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/callback-interface.cc.template
diff --git a/src/cobalt/bindings/v8c/templates/callback-interface.h.template b/src/cobalt/bindings/v8c/templates/callback-interface.h.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/callback-interface.h.template
diff --git a/src/cobalt/bindings/v8c/templates/dictionary-conversion.cc.template b/src/cobalt/bindings/v8c/templates/dictionary-conversion.cc.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/dictionary-conversion.cc.template
diff --git a/src/cobalt/bindings/v8c/templates/enumeration-conversion.cc.template b/src/cobalt/bindings/v8c/templates/enumeration-conversion.cc.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/enumeration-conversion.cc.template
diff --git a/src/cobalt/bindings/v8c/templates/generated-types.h.template b/src/cobalt/bindings/v8c/templates/generated-types.h.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/generated-types.h.template
diff --git a/src/cobalt/bindings/v8c/templates/interface.cc.template b/src/cobalt/bindings/v8c/templates/interface.cc.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/interface.cc.template
diff --git a/src/cobalt/bindings/v8c/templates/interface.h.template b/src/cobalt/bindings/v8c/templates/interface.h.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/interface.h.template
diff --git a/src/cobalt/bindings/v8c/templates/macros.cc.template b/src/cobalt/bindings/v8c/templates/macros.cc.template new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/cobalt/bindings/v8c/templates/macros.cc.template
diff --git a/src/cobalt/browser/application.cc b/src/cobalt/browser/application.cc index aa2919a..a946dee 100644 --- a/src/cobalt/browser/application.cc +++ b/src/cobalt/browser/application.cc
@@ -587,6 +587,9 @@ if (command_line->HasSwitch(switches::kDisableImageAnimations)) { options.web_module_options.enable_image_animations = false; } + if (command_line->HasSwitch(switches::kDisableSplashScreenOnReloads)) { + options.enable_splash_screen_on_reloads = false; + } #endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES // Production-builds override all switches to the most secure configuration. @@ -736,9 +739,9 @@ case kSbEventTypeUnpause: case kSbEventTypeSuspend: case kSbEventTypeResume: -#if SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypeLowMemory: -#endif // SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#endif // SB_API_VERSION >= 6 OnApplicationEvent(starboard_event->type); break; case kSbEventTypeNetworkConnect: @@ -828,13 +831,13 @@ browser_module_->Resume(); DLOG(INFO) << "Finished resuming."; break; -#if SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypeLowMemory: DLOG(INFO) << "Got low memory event."; browser_module_->ReduceMemory(); DLOG(INFO) << "Finished reducing memory usage."; break; -#endif // SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#endif // SB_API_VERSION >= 6 default: NOTREACHED() << "Unexpected event type: " << event_type; return;
diff --git a/src/cobalt/browser/browser_module.cc b/src/cobalt/browser/browser_module.cc index 4294695..4322073 100644 --- a/src/cobalt/browser/browser_module.cc +++ b/src/cobalt/browser/browser_module.cc
@@ -228,6 +228,7 @@ web_module_loaded_(true /* manually_reset */, false /* initially_signalled */), web_module_recreated_callback_(options_.web_module_recreated_callback), + navigate_count_(0), navigate_time_("Time.Browser.Navigate", 0, "The last time a navigation occurred."), on_load_event_time_("Time.Browser.OnLoadEvent", 0, @@ -281,6 +282,16 @@ #endif TRACE_EVENT0("cobalt::browser", "BrowserModule::BrowserModule()"); + // Create the main web module layer. + main_web_module_layer_ = + render_tree_combiner_.CreateLayer(kMainWebModuleZIndex); + // Create the splash screen layer. + splash_screen_layer_ = render_tree_combiner_.CreateLayer(kSplashScreenZIndex); +// Create the debug console layer. +#if defined(ENABLE_DEBUG_CONSOLE) + debug_console_layer_ = render_tree_combiner_.CreateLayer(kDebugConsoleZIndex); +#endif + // Setup our main web module to have the H5VCC API injected into it. DCHECK(!ContainsKey(options_.web_module_options.injected_window_attributes, "h5vcc")); @@ -407,30 +418,27 @@ // Wait until after the old WebModule is destroyed before setting the navigate // time so that it won't be included in the time taken to load the URL. + ++navigate_count_; navigate_time_ = base::TimeTicks::Now().ToInternalValue(); // Show a splash screen while we're waiting for the web page to load. const math::Size& viewport_size = GetViewportSize(); DestroySplashScreen(base::TimeDelta()); - base::optional<std::string> key = SplashScreenCache::GetKeyForStartUrl(url); - if (fallback_splash_screen_url_ || - (key && splash_screen_cache_->IsSplashScreenCached(*key))) { - // Create the splash screen layer. - if (render_tree_combiner_) { - splash_screen_layer_ = - render_tree_combiner_->CreateLayer(kSplashScreenZIndex); + if (options_.enable_splash_screen_on_reloads || navigate_count_ == 1) { + base::optional<std::string> key = SplashScreenCache::GetKeyForStartUrl(url); + if (fallback_splash_screen_url_ || + (key && splash_screen_cache_->IsSplashScreenCached(*key))) { + splash_screen_.reset(new SplashScreen( + application_state_, + base::Bind(&BrowserModule::QueueOnSplashScreenRenderTreeProduced, + base::Unretained(this)), + &network_module_, viewport_size, GetResourceProvider(), + kLayoutMaxRefreshFrequencyInHz, fallback_splash_screen_url_, url, + splash_screen_cache_.get(), + base::Bind(&BrowserModule::DestroySplashScreen, weak_this_))); + lifecycle_observers_.AddObserver(splash_screen_.get()); } - - splash_screen_.reset(new SplashScreen( - application_state_, - base::Bind(&BrowserModule::QueueOnSplashScreenRenderTreeProduced, - base::Unretained(this)), - &network_module_, viewport_size, GetResourceProvider(), - kLayoutMaxRefreshFrequencyInHz, fallback_splash_screen_url_, url, - splash_screen_cache_.get(), - base::Bind(&BrowserModule::DestroySplashScreen, weak_this_))); - lifecycle_observers_.AddObserver(splash_screen_.get()); } // Create new WebModule. @@ -594,8 +602,7 @@ if (splash_screen_ && !splash_screen_->ShutdownSignaled()) { splash_screen_->Shutdown(); } - if (application_state_ == base::kApplicationStatePreloading || - !render_tree_combiner_ || !main_web_module_layer_) { + if (application_state_ == base::kApplicationStatePreloading) { return; } @@ -610,7 +617,7 @@ renderer_submission.on_rasterized_callback = base::Bind( &BrowserModule::OnRendererSubmissionRasterized, base::Unretained(this)); if (!splash_screen_) { - render_tree_combiner_->SetTimelineLayer(main_web_module_layer_.get()); + render_tree_combiner_.SetTimelineLayer(main_web_module_layer_.get()); } main_web_module_layer_->Submit(renderer_submission); @@ -628,7 +635,7 @@ DCHECK_EQ(MessageLoop::current(), self_message_loop_); if (application_state_ == base::kApplicationStatePreloading || - !render_tree_combiner_ || !splash_screen_layer_) { + !splash_screen_) { return; } @@ -654,7 +661,7 @@ renderer_submission.on_rasterized_callback = base::Bind( &BrowserModule::OnRendererSubmissionRasterized, base::Unretained(this)); - render_tree_combiner_->SetTimelineLayer(splash_screen_layer_.get()); + render_tree_combiner_.SetTimelineLayer(splash_screen_layer_.get()); splash_screen_layer_->Submit(renderer_submission); #if defined(ENABLE_SCREENSHOT) @@ -750,8 +757,7 @@ TRACE_EVENT0("cobalt::browser", "BrowserModule::OnDebugConsoleRenderTreeProduced()"); DCHECK_EQ(MessageLoop::current(), self_message_loop_); - if (application_state_ == base::kApplicationStatePreloading || - !render_tree_combiner_ || !debug_console_layer_) { + if (application_state_ == base::kApplicationStatePreloading) { return; } @@ -967,18 +973,16 @@ } if (splash_screen_) { lifecycle_observers_.RemoveObserver(splash_screen_.get()); - } - if (splash_screen_layer_) { - if (!close_time.is_zero()) { + if (!close_time.is_zero() && renderer_module_) { // Ensure that the renderer renders each frame up until the window.close() // is called on the splash screen's timeline, in order to ensure that the // splash screen shutdown transition plays out completely. renderer_module_->pipeline()->TimeFence(close_time); } - splash_screen_layer_.reset(NULL); + splash_screen_layer_->Reset(); SubmitCurrentRenderTreeToRenderer(); + splash_screen_.reset(NULL); } - splash_screen_.reset(NULL); } #if defined(ENABLE_WEBDRIVER) @@ -1208,16 +1212,6 @@ RendererModuleWithCameraOptions(options_.renderer_module_options, input_device_manager_->camera_3d()))); - render_tree_combiner_.reset(new RenderTreeCombiner()); - // Create the main web module layer. - main_web_module_layer_ = - render_tree_combiner_->CreateLayer(kMainWebModuleZIndex); -// Create the debug console layer. -#if defined(ENABLE_DEBUG_CONSOLE) - debug_console_layer_ = - render_tree_combiner_->CreateLayer(kDebugConsoleZIndex); -#endif - #if defined(ENABLE_SCREENSHOT) screen_shot_writer_.reset(new ScreenShotWriter(renderer_module_->pipeline())); #endif // defined(ENABLE_SCREENSHOT) @@ -1273,15 +1267,9 @@ // Clear out the render tree combiner so that it doesn't hold on to any // render tree resources either. - if (main_web_module_layer_) { - main_web_module_layer_->Reset(); - } - if (splash_screen_layer_) { - splash_screen_layer_->Reset(); - } - if (debug_console_layer_) { - debug_console_layer_->Reset(); - } + main_web_module_layer_->Reset(); + splash_screen_layer_->Reset(); + debug_console_layer_->Reset(); #if defined(ENABLE_GPU_ARRAY_BUFFER_ALLOCATOR) // Note that the following function call will leak the GPU memory allocated. @@ -1419,8 +1407,12 @@ } void BrowserModule::SubmitCurrentRenderTreeToRenderer() { + if (!renderer_module_) { + return; + } + base::optional<renderer::Submission> submission = - render_tree_combiner_->GetCurrentSubmission(); + render_tree_combiner_.GetCurrentSubmission(); if (submission) { renderer_module_->pipeline()->Submit(*submission); }
diff --git a/src/cobalt/browser/browser_module.h b/src/cobalt/browser/browser_module.h index 32ec219..6f95f5c 100644 --- a/src/cobalt/browser/browser_module.h +++ b/src/cobalt/browser/browser_module.h
@@ -75,8 +75,8 @@ : web_module_options(web_options), command_line_auto_mem_settings( memory_settings::AutoMemSettings::kTypeCommandLine), - build_auto_mem_settings( - memory_settings::AutoMemSettings::kTypeBuild) {} + build_auto_mem_settings(memory_settings::AutoMemSettings::kTypeBuild), + enable_splash_screen_on_reloads(true) {} network::NetworkModule::Options network_module_options; renderer::RendererModule::Options renderer_module_options; storage::StorageManager::Options storage_manager_options; @@ -89,6 +89,7 @@ memory_settings::AutoMemSettings build_auto_mem_settings; base::optional<GURL> fallback_splash_screen_url; base::optional<math::Size> requested_viewport_size; + bool enable_splash_screen_on_reloads; }; // Type for a collection of URL handler callbacks that can potentially handle @@ -393,7 +394,7 @@ network::NetworkModule network_module_; // Manages the three render trees, combines and renders them. - scoped_ptr<RenderTreeCombiner> render_tree_combiner_; + RenderTreeCombiner render_tree_combiner_; scoped_ptr<RenderTreeCombiner::Layer> main_web_module_layer_; scoped_ptr<RenderTreeCombiner::Layer> debug_console_layer_; scoped_ptr<RenderTreeCombiner::Layer> splash_screen_layer_; @@ -423,6 +424,9 @@ // which could occur on navigation. base::Closure web_module_recreated_callback_; + // The total number of navigations that have occurred. + int navigate_count_; + // The time when a URL navigation starts. This is recorded after the previous // WebModule is destroyed. base::CVal<int64> navigate_time_;
diff --git a/src/cobalt/browser/switches.cc b/src/cobalt/browser/switches.cc index 4d028b2..12bbc04 100644 --- a/src/cobalt/browser/switches.cc +++ b/src/cobalt/browser/switches.cc
@@ -26,6 +26,13 @@ // Switches different debug console modes: on | hud | off const char kDebugConsoleMode[] = "debug_console"; +// Enables/disables animations on animated images (e.g. animated WebP). +const char kDisableImageAnimations[] = "disable_image_animations"; + +// Disables the splash screen on reloads; instead it will only appear on the +// first navigate. +const char kDisableSplashScreenOnReloads[] = "disable_splash_screen_on_reloads"; + // Do not create the WebDriver server. const char kDisableWebDriver[] = "disable_webdriver"; @@ -119,9 +126,6 @@ // Enables memory tracking by installing the memory tracker on startup. const char kMemoryTracker[] = "memory_tracker"; -// Enables/disables animations on animated images (e.g. animated WebP). -const char kDisableImageAnimations[] = "disable_image_animations"; - #endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES // If toggled, framerate statistics will be printed to stdout after each
diff --git a/src/cobalt/browser/switches.h b/src/cobalt/browser/switches.h index c9edfc3..dd36528 100644 --- a/src/cobalt/browser/switches.h +++ b/src/cobalt/browser/switches.h
@@ -22,6 +22,8 @@ #if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) extern const char kAudioDecoderStub[]; extern const char kDebugConsoleMode[]; +extern const char kDisableImageAnimations[]; +extern const char kDisableSplashScreenOnReloads[]; extern const char kDisableWebDriver[]; extern const char kDisableWebmVp9[]; extern const char kExtraWebFileDir[]; @@ -44,7 +46,6 @@ extern const char kVideoDecoderStub[]; extern const char kWebDriverListenIp[]; extern const char kWebDriverPort[]; -extern const char kDisableImageAnimations[]; #endif // ENABLE_DEBUG_COMMAND_LINE_SWITCHES extern const char kDisableNavigationWhitelist[];
diff --git a/src/cobalt/build/build.id b/src/cobalt/build/build.id index 3e535a7..36f609f 100644 --- a/src/cobalt/build/build.id +++ b/src/cobalt/build/build.id
@@ -1 +1 @@ -102542 \ No newline at end of file +103164 \ No newline at end of file
diff --git a/src/cobalt/build/build_config.h b/src/cobalt/build/build_config.h index e743e5f..527f9bc 100644 --- a/src/cobalt/build/build_config.h +++ b/src/cobalt/build/build_config.h
@@ -51,11 +51,10 @@ // COBALT_MEDIA_BUFFER_VIDEO_BUDGET_1080P #if COBALT_ENCRYPTED_MEDIA_EXTENSION_ENABLE_KEY_STATUSES_UPDATE -#if SB_API_VERSION < SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION < 6 #error COBALT_ENCRYPTED_MEDIA_EXTENSION_ENABLE_KEY_STATUSES_UPDATE requires \ - that SB_API_VERSION is greater than or equal to \ - SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION -#endif // SB_API_VERSION < SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION + that SB_API_VERSION is greater than or equal to 6 +#endif // SB_API_VERSION < 6 #endif // COBALT_ENCRYPTED_MEDIA_EXTENSION_ENABLE_KEY_STATUSES_UPDATE #endif // COBALT_BUILD_BUILD_CONFIG_H_
diff --git a/src/cobalt/build/config/base.gypi b/src/cobalt/build/config/base.gypi index 1f837c1..867adb5 100644 --- a/src/cobalt/build/config/base.gypi +++ b/src/cobalt/build/config/base.gypi
@@ -466,11 +466,14 @@ # as expected, rather than requiring it to be set for each platform. #'javascript_engine%': 'mozjs-45', - # Disable jit and run in interpreter-only mode by default. It can be set to - # 1 to run in jit mode. We have found that disabling jit often results in - # faster JavaScript execution and lower memory usage. + # Disable JIT and run in interpreter-only mode by default. It can be set + # to 1 to run in JIT mode. For SpiderMonkey in particular, we have found + # that disabling JIT often results in faster JavaScript execution and + # lower memory usage. # Setting this to 1 on a platform or engine for which there is no JIT # implementation is a no-op. + # Setting this to 0 on an engine for which there is a JIT implementation + # is a platform configuration error. 'cobalt_enable_jit%': 0, # Can be set to enable zealous garbage collection, if |javascript_engine|
diff --git a/src/cobalt/dom/eme/media_key_session.cc b/src/cobalt/dom/eme/media_key_session.cc index b2d8205..11c2f98 100644 --- a/src/cobalt/dom/eme/media_key_session.cc +++ b/src/cobalt/dom/eme/media_key_session.cc
@@ -37,11 +37,11 @@ : ALLOW_THIS_IN_INITIALIZER_LIST(event_queue_(this)), drm_system_(drm_system), drm_system_session_(drm_system->CreateSession( -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 base::Bind(&MediaKeySession::OnSessionUpdateKeyStatuses, base::AsWeakPtr(this)) -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION - )), +#endif // SB_API_VERSION >= 6 + )), script_value_factory_(script_value_factory), uninitialized_(true), callable_(false),
diff --git a/src/cobalt/input/input_device_manager_desktop.cc b/src/cobalt/input/input_device_manager_desktop.cc index d49fb15..983da10 100644 --- a/src/cobalt/input/input_device_manager_desktop.cc +++ b/src/cobalt/input/input_device_manager_desktop.cc
@@ -77,7 +77,7 @@ static_cast<uint32_t>(kSbKeyModifiersShift) == system_window::InputEvent::kShiftKey, Mismatched_modifier_enums); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 COMPILE_ASSERT(static_cast<uint32_t>(kSbKeyModifiersPointerButtonLeft) == system_window::InputEvent::kLeftButton && static_cast<uint32_t>(kSbKeyModifiersPointerButtonRight) == @@ -89,7 +89,7 @@ static_cast<uint32_t>(kSbKeyModifiersPointerButtonForward) == system_window::InputEvent::kForwardButton, Mismatched_modifier_enums); -#endif +#endif // SB_API_VERSION >= 6 void UpdateEventModifierInit(const system_window::InputEvent* input_event, EventModifierInit* event) { @@ -221,7 +221,7 @@ break; } pointer_event.set_pointer_id(input_event->device_id()); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 pointer_event.set_width(value_or(input_event->size().x(), 0.0f)); pointer_event.set_height(value_or(input_event->size().y(), 0.0f)); pointer_event.set_pressure(value_or(input_event->pressure(), @@ -230,7 +230,7 @@ value_or(static_cast<float>(input_event->tilt().x()), 0.0f)); pointer_event.set_tilt_y( value_or(static_cast<float>(input_event->tilt().y()), 0.0f)); -#endif +#endif // SB_API_VERSION >= 6 pointer_event.set_is_primary(true); pointer_event_callback_.Run(type, pointer_event); }
diff --git a/src/cobalt/media/base/drm_system.cc b/src/cobalt/media/base/drm_system.cc index c3f4d23..8b5516b 100644 --- a/src/cobalt/media/base/drm_system.cc +++ b/src/cobalt/media/base/drm_system.cc
@@ -20,7 +20,7 @@ namespace cobalt { namespace media { -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 DrmSystem::Session::Session( DrmSystem* drm_system, SessionUpdateKeyStatusesCallback update_key_statuses_callback) @@ -29,10 +29,10 @@ closed_(false) { DCHECK(!update_key_statuses_callback_.is_null()); } -#else // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#else // SB_API_VERSION >= 6 DrmSystem::Session::Session(DrmSystem* drm_system) : drm_system_(drm_system), closed_(false) {} -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 DrmSystem::Session::~Session() { if (id_ && !closed_) { @@ -77,10 +77,10 @@ : wrapped_drm_system_(SbDrmCreateSystem(key_system, this, OnSessionUpdateRequestGeneratedFunc, OnSessionUpdatedFunc -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 , OnSessionKeyStatusesChangedFunc -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 )), message_loop_(MessageLoop::current()), ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), @@ -92,17 +92,17 @@ DrmSystem::~DrmSystem() { SbDrmDestroySystem(wrapped_drm_system_); } -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 scoped_ptr<DrmSystem::Session> DrmSystem::CreateSession( SessionUpdateKeyStatusesCallback session_update_key_statuses_callback) { return make_scoped_ptr( new Session(this, session_update_key_statuses_callback)); } -#else // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#else // SB_API_VERSION >= 6 scoped_ptr<DrmSystem::Session> DrmSystem::CreateSession() { return make_scoped_ptr(new Session(this)); } -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 void DrmSystem::GenerateSessionUpdateRequest( Session* session, const std::string& type, const uint8_t* init_data, @@ -226,7 +226,7 @@ ticket_to_session_update_map_.erase(session_update_iterator); } -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 void DrmSystem::OnSessionKeyStatusChanged( const std::string& session_id, const std::vector<std::string>& key_ids, const std::vector<SbDrmKeyStatus>& key_statuses) { @@ -241,7 +241,7 @@ session->update_key_statuses_callback().Run(key_ids, key_statuses); } -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 // static void DrmSystem::OnSessionUpdateRequestGeneratedFunc( @@ -283,7 +283,7 @@ drm_system->weak_this_, ticket, succeeded)); } -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 // static void DrmSystem::OnSessionKeyStatusesChangedFunc( SbDrmSystem wrapped_drm_system, void* context, const void* session_id, @@ -315,7 +315,7 @@ base::Bind(&DrmSystem::OnSessionKeyStatusChanged, drm_system->weak_this_, session_id_copy, key_ids_copy, key_statuses_copy)); } -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 } // namespace media } // namespace cobalt
diff --git a/src/cobalt/media/base/drm_system.h b/src/cobalt/media/base/drm_system.h index b0a26ff..f60ad9d 100644 --- a/src/cobalt/media/base/drm_system.h +++ b/src/cobalt/media/base/drm_system.h
@@ -40,11 +40,11 @@ typedef base::Callback<void()> SessionUpdateRequestDidNotGenerateCallback; typedef base::Callback<void()> SessionUpdatedCallback; typedef base::Callback<void()> SessionDidNotUpdateCallback; -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 typedef base::Callback<void(const std::vector<std::string>& key_ids, const std::vector<SbDrmKeyStatus>& key_statuses)> SessionUpdateKeyStatusesCallback; -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 // Flyweight that provides RAII semantics for sessions. // Most of logic is implemented by |DrmSystem| and thus sessions must be @@ -89,31 +89,31 @@ private: // Private API for |DrmSystem|. Session(DrmSystem* drm_system -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 , SessionUpdateKeyStatusesCallback update_key_statuses_callback -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 ); // NOLINT(whitespace/parens) void set_id(const std::string& id) { id_ = id; } const SessionUpdateRequestGeneratedCallback& update_request_generated_callback() const { return update_request_generated_callback_; } -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 const SessionUpdateKeyStatusesCallback& update_key_statuses_callback() const { return update_key_statuses_callback_; } -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 DrmSystem* const drm_system_; bool closed_; base::optional<std::string> id_; // Supports spontaneous invocations of |SbDrmSessionUpdateRequestFunc|. SessionUpdateRequestGeneratedCallback update_request_generated_callback_; -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 SessionUpdateKeyStatusesCallback update_key_statuses_callback_; -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 friend class DrmSystem; @@ -126,9 +126,9 @@ SbDrmSystem wrapped_drm_system() { return wrapped_drm_system_; } scoped_ptr<Session> CreateSession( -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 SessionUpdateKeyStatusesCallback session_update_key_statuses_callback -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 ); // NOLINT(whitespace/parens) private: @@ -169,11 +169,11 @@ int ticket, const base::optional<std::string>& session_id, scoped_array<uint8> message, int message_size); void OnSessionUpdated(int ticket, bool succeeded); -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 void OnSessionKeyStatusChanged( const std::string& session_id, const std::vector<std::string>& key_ids, const std::vector<SbDrmKeyStatus>& key_statuses); -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 // Called on any thread, parameters need to be copied immediately. static void OnSessionUpdateRequestGeneratedFunc( @@ -184,12 +184,12 @@ void* context, int ticket, const void* session_id, int session_id_length, bool succeeded); -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 static void OnSessionKeyStatusesChangedFunc( SbDrmSystem wrapped_drm_system, void* context, const void* session_id, int session_id_size, int number_of_keys, const SbDrmKeyId* key_ids, const SbDrmKeyStatus* key_statuses); -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 const SbDrmSystem wrapped_drm_system_; MessageLoop* const message_loop_;
diff --git a/src/cobalt/media/base/sbplayer_pipeline.cc b/src/cobalt/media/base/sbplayer_pipeline.cc index bf397d8..4844a7d 100644 --- a/src/cobalt/media/base/sbplayer_pipeline.cc +++ b/src/cobalt/media/base/sbplayer_pipeline.cc
@@ -705,7 +705,7 @@ void SbPlayerPipeline::OnDemuxerSeeked(PipelineStatus status) { DCHECK(message_loop_->BelongsToCurrentThread()); - if (status == PIPELINE_OK) { + if (status == PIPELINE_OK && player_) { player_->Seek(seek_time_); } }
diff --git a/src/cobalt/media/base/starboard_player.cc b/src/cobalt/media/base/starboard_player.cc index 68bb5ec..4582565 100644 --- a/src/cobalt/media/base/starboard_player.cc +++ b/src/cobalt/media/base/starboard_player.cc
@@ -185,12 +185,12 @@ } SbPlayerWriteSample(player_, DemuxerStreamTypeToSbMediaType(type), -#if SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#if SB_API_VERSION >= 6 allocations.buffers(), allocations.buffer_sizes(), -#else // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#else // SB_API_VERSION >= 6 const_cast<const void**>(allocations.buffers()), const_cast<int*>(allocations.buffer_sizes()), -#endif // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#endif // SB_API_VERSION >= 6 allocations.number_of_buffers(), TimeDeltaToSbMediaTime(buffer->timestamp()), type == DemuxerStream::VIDEO ? &video_info : NULL,
diff --git a/src/cobalt/media/base/starboard_utils.cc b/src/cobalt/media/base/starboard_utils.cc index f184538..b5cf1c6 100644 --- a/src/cobalt/media/base/starboard_utils.cc +++ b/src/cobalt/media/base/starboard_utils.cc
@@ -68,7 +68,7 @@ audio_header.block_alignment = 4; audio_header.bits_per_sample = audio_decoder_config.bits_per_channel(); -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 audio_header.audio_specific_config_size = static_cast<uint16_t>(audio_decoder_config.extra_data().size()); if (audio_header.audio_specific_config_size == 0) { @@ -76,7 +76,7 @@ } else { audio_header.audio_specific_config = &audio_decoder_config.extra_data()[0]; } -#else // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#else // SB_API_VERSION >= 6 audio_header.audio_specific_config_size = static_cast<uint16_t>( std::min(audio_decoder_config.extra_data().size(), sizeof(audio_header.audio_specific_config))); @@ -85,7 +85,7 @@ &audio_decoder_config.extra_data()[0], audio_header.audio_specific_config_size); } -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 return audio_header; }
diff --git a/src/cobalt/renderer/rasterizer/egl/hardware_rasterizer.cc b/src/cobalt/renderer/rasterizer/egl/hardware_rasterizer.cc index 6043afa..f845dc8 100644 --- a/src/cobalt/renderer/rasterizer/egl/hardware_rasterizer.cc +++ b/src/cobalt/renderer/rasterizer/egl/hardware_rasterizer.cc
@@ -139,6 +139,13 @@ backend::RenderTargetEGL* render_target_egl = base::polymorphic_downcast<backend::RenderTargetEGL*>( render_target.get()); + + // Skip rendering if we lost the surface. This can happen just before suspend + // on Android, so now we're just waiting for the suspend to clean up. + if (render_target_egl->is_surface_bad()) { + return; + } + backend::GraphicsContextEGL::ScopedMakeCurrent scoped_make_current( graphics_context_, render_target_egl);
diff --git a/src/cobalt/renderer/rasterizer/egl/textured_mesh_renderer.cc b/src/cobalt/renderer/rasterizer/egl/textured_mesh_renderer.cc index 8df6fd1..0812b2e 100644 --- a/src/cobalt/renderer/rasterizer/egl/textured_mesh_renderer.cc +++ b/src/cobalt/renderer/rasterizer/egl/textured_mesh_renderer.cc
@@ -489,7 +489,7 @@ } break; case Image::YUV_2PLANE_BT709: { std::vector<TextureInfo> texture_infos; -#if SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#if SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION switch (image.textures[0].texture->GetFormat()) { case GL_ALPHA: texture_infos.push_back(TextureInfo("y", "a")); @@ -514,10 +514,10 @@ default: NOTREACHED(); } -#else // SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#else // SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION texture_infos.push_back(TextureInfo("y", "a")); texture_infos.push_back(TextureInfo("uv", "ba")); -#endif // SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#endif // SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION result = MakeBlitProgram( color_matrix, texture_infos, CreateFragmentShader(texture_target, texture_infos));
diff --git a/src/cobalt/renderer/rasterizer/skia/hardware_resource_provider.cc b/src/cobalt/renderer/rasterizer/skia/hardware_resource_provider.cc index ce39cca..e7e9075 100644 --- a/src/cobalt/renderer/rasterizer/skia/hardware_resource_provider.cc +++ b/src/cobalt/renderer/rasterizer/skia/hardware_resource_provider.cc
@@ -149,13 +149,10 @@ #if SB_HAS(GRAPHICS) namespace { -#if SB_API_VERSION < SB_DECODE_TARGET_PLANES_FOR_FORMAT +#if SB_API_VERSION < 6 int PlanesPerFormat(SbDecodeTargetFormat format) { switch (format) { case kSbDecodeTargetFormat1PlaneRGBA: -#if SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION - case kSbDecodeTargetFormat1PlaneUYVY: -#endif // SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION return 1; case kSbDecodeTargetFormat1PlaneBGRA: return 1; @@ -168,26 +165,26 @@ return 0; } } -#endif // SB_API_VERSION < SB_DECODE_TARGET_PLANES_FOR_FORMAT +#endif // SB_API_VERSION < 6 uint32_t DecodeTargetFormatToGLFormat(SbDecodeTargetFormat format, int plane, const SbDecodeTargetInfoPlane* plane_info) { switch (format) { case kSbDecodeTargetFormat1PlaneRGBA: -#if SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 // For UYVY, we will use a fragment shader where R = the first U, G = Y, // B = the second U, and A = V. case kSbDecodeTargetFormat1PlaneUYVY: -#endif // SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 { DCHECK_EQ(0, plane); return GL_RGBA; } break; case kSbDecodeTargetFormat2PlaneYUVNV12: { DCHECK_LT(plane, 2); -#if SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#if SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION // If this DCHECK fires, please set gl_texture_format, introduced - // in Starboard SB_DECODE_TARGET_FORMAT_VERSION. + // in Starboard SB_DECODE_TARGET_PLANE_FORMAT_VERSION. // // You probably want to set it to GL_ALPHA on plane 0 (luma) and // GL_LUMINANCE_ALPHA on plane 1 (chroma), which was the default before. @@ -209,7 +206,7 @@ CHECK(false); return 0; } -#else // SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#else // SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION switch (plane) { case 0: return GL_ALPHA; @@ -219,7 +216,7 @@ NOTREACHED(); return GL_RGBA; } -#endif // SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#endif // SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION } break; case kSbDecodeTargetFormat3PlaneYUVI420: { DCHECK_LT(plane, 3); @@ -283,11 +280,11 @@ new DecodeTargetReferenceCounted(decode_target)); // There is limited format support at this time. -#if SB_API_VERSION >= SB_DECODE_TARGET_PLANES_FOR_FORMAT +#if SB_API_VERSION >= 6 int planes_per_format = SbDecodeTargetNumberOfPlanesForFormat(info.format); #else int planes_per_format = PlanesPerFormat(info.format); -#endif // SB_API_VERSION >= SB_DECODE_TARGET_PLANES_FOR_FORMAT +#endif // SB_API_VERSION >= 6 for (int i = 0; i < planes_per_format; ++i) { const SbDecodeTargetInfoPlane& plane = info.planes[i]; @@ -318,11 +315,11 @@ // this in as supplementary data, as the |texture| object only knows that // it is RGBA. base::optional<AlternateRgbaFormat> alternate_rgba_format; -#if SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 if (info.format == kSbDecodeTargetFormat1PlaneUYVY) { alternate_rgba_format = AlternateRgbaFormat_UYVY; } -#endif // SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 planes.push_back(make_scoped_refptr(new HardwareFrontendImage( texture.Pass(), alpha_format, cobalt_context_, gr_context_,
diff --git a/src/cobalt/script/engine.gyp b/src/cobalt/script/engine.gyp index d5423b8..342bcb5 100644 --- a/src/cobalt/script/engine.gyp +++ b/src/cobalt/script/engine.gyp
@@ -22,8 +22,9 @@ 'sources': [ 'javascript_engine.h', ], - 'dependencies': [ - '<(javascript_engine)/<(javascript_engine).gyp:engine', + 'conditions': [ + [ 'javascript_engine == "mozjs-45"', { 'dependencies': ['mozjs-45/mozjs-45.gyp:engine', ], }, ], + [ 'javascript_engine == "v8"', { 'dependencies': ['v8c/v8c.gyp:engine', ], }, ], ], }, {
diff --git a/src/cobalt/script/engine_variables.gypi b/src/cobalt/script/engine_variables.gypi index d60625c..54fe07e 100644 --- a/src/cobalt/script/engine_variables.gypi +++ b/src/cobalt/script/engine_variables.gypi
@@ -15,5 +15,6 @@ { 'includes': [ 'mozjs-45/mozjs-45_variables.gypi', + 'v8c/v8c_variables.gypi', ], }
diff --git a/src/cobalt/script/global_environment.h b/src/cobalt/script/global_environment.h index 039f05d..9676f73 100644 --- a/src/cobalt/script/global_environment.h +++ b/src/cobalt/script/global_environment.h
@@ -92,7 +92,8 @@ virtual void EnableEval() = 0; // Disable just-in-time compilation of JavaScript source code to native - // code. Calling this is a no-op if JIT was not enabled in the first place. + // code. Calling this is a no-op if JIT was not enabled in the first place, + // or if the engine does not support disabling JIT. virtual void DisableJit() = 0; // Set a callback that will be fired whenever eval() or a Function()
diff --git a/src/cobalt/script/v8c/v8c.cc b/src/cobalt/script/v8c/v8c.cc new file mode 100644 index 0000000..993cc58 --- /dev/null +++ b/src/cobalt/script/v8c/v8c.cc
@@ -0,0 +1,119 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <iostream> + +#include "base/command_line.h" +#include "base/file_path.h" +#include "base/string_util.h" +#include "cobalt/base/wrap_main.h" +#include "cobalt/script/source_code.h" +#include "cobalt/script/standalone_javascript_runner.h" +#include "cobalt/script/v8c/v8c_global_environment.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8.h" + +namespace cobalt { +namespace script { +namespace v8c { +namespace { + +void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { + v8::Isolate* isolate = args.GetIsolate(); + v8::HandleScope scope(isolate); + + std::vector<std::string> string_args; + for (int i = 0; i < args.Length(); i++) { + v8::TryCatch try_catch(args.GetIsolate()); + v8::Local<v8::Value> arg = args[i]; + v8::Local<v8::String> string; + + if (arg->IsSymbol()) { + arg = v8::Local<v8::Symbol>::Cast(arg)->Name(); + } + if (!arg->ToString(args.GetIsolate()->GetCurrentContext()) + .ToLocal(&string)) { + try_catch.ReThrow(); + return; + } + + v8::String::Utf8Value utf8_value(args.GetIsolate(), string); + string_args.push_back(*utf8_value); + } + + std::string joined = JoinString(string_args, ' '); + std::cout << joined << std::endl; +} + +void SetupBindings(GlobalEnvironment* global_environment) { + V8cGlobalEnvironment* v8c_global_environment = + static_cast<V8cGlobalEnvironment*>(global_environment); + v8::Isolate* isolate = v8c_global_environment->isolate(); + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + auto context = v8c_global_environment->context(); + v8::Context::Scope context_scope(context); + context->Global()->Set( + v8::String::NewFromUtf8(isolate, "print", v8::NewStringType::kNormal) + .ToLocalChecked(), + v8::Function::New(isolate, Print)); +} + +int V8cMain(int argc, char** argv) { + cobalt::script::StandaloneJavascriptRunner standalone_runner; + GlobalEnvironment* global_environment = + standalone_runner.global_environment().get(); + SetupBindings(global_environment); + if (argc > 1) { + // Command line arguments will be flag-value pairs of the form + // -f filename + // and + // -e "inline script" + // and will be evaluated in order. + for (int i = 1; (i + 1) < argc; ++i) { + if (std::string(argv[i]) == "-f") { + std::string filename = std::string(argv[i + 1]); + // Execute source file. + FilePath source_file(filename); + standalone_runner.ExecuteFile(source_file); + ++i; + } else if (std::string(argv[i]) == "-e") { + // Execute inline script. + scoped_refptr<SourceCode> source = SourceCode::CreateSourceCode( + argv[i + 1], base::SourceLocation("[stdin]", 1, 1)); + + // Execute the script and get the results of execution. + std::string result; + bool success = global_environment->EvaluateScript(source, &result); + // Echo the results to stdout. + if (!success) { + std::cout << "Exception: "; + } + std::cout << result << std::endl; + ++i; + } + } + } else { + standalone_runner.RunInteractive(); + } + + return 0; +} + +} // namespace +} // namespace v8c +} // namespace script +} // namespace cobalt + +COBALT_WRAP_SIMPLE_MAIN(cobalt::script::v8c::V8cMain);
diff --git a/src/cobalt/script/v8c/v8c.gyp b/src/cobalt/script/v8c/v8c.gyp new file mode 100644 index 0000000..dc9b560 --- /dev/null +++ b/src/cobalt/script/v8c/v8c.gyp
@@ -0,0 +1,70 @@ +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + 'targets': [ + { + 'target_name': 'engine', + 'type': 'static_library', + 'sources': [ + 'v8c_engine.cc', + 'v8c_engine.h', + 'v8c_global_environment.cc', + 'v8c_global_environment.h', + 'v8c_source_code.cc', + 'v8c_source_code.h', + ], + 'dependencies': [ + '<(DEPTH)/v8/src/v8.gyp:v8', + '<(DEPTH)/v8/src/v8.gyp:v8_libplatform', + ], + 'defines': [ + 'ENGINE_SUPPORTS_INT64', + 'ENGINE_SUPPORTS_JIT', + ], + 'all_dependent_settings': { + 'defines': [ + 'ENGINE_SUPPORTS_INDEXED_DELETERS', + 'ENGINE_SUPPORTS_INT64', + 'ENGINE_SUPPORTS_STACK_TRACE_COLUMNS', + # TODO: Remove this when exact rooting and generational GC is enabled. + 'ENGINE_USES_CONSERVATIVE_ROOTING', + ], + }, + # V8 always requires JIT. |cobalt_enable_jit| must be set to true to + # use V8. Failure to do will result in a build failure. + 'conditions' :[ + ['cobalt_enable_jit == 0', { + 'defines': [ '<(gyp_static_assert_false)', ], + }], + ], + }, + + { + # Standalone shell executable for V8 within Cobalt. + 'target_name': 'v8c', + 'type': '<(final_executable_type)', + 'sources': [ + 'v8c.cc', + ], + 'dependencies': [ + ':engine', + '<(DEPTH)/cobalt/base/base.gyp:base', + '<(DEPTH)/cobalt/script/script.gyp:standalone_javascript_runner', + '<(DEPTH)/v8/src/v8.gyp:v8', + '<(DEPTH)/v8/src/v8.gyp:v8_libplatform', + ], + }, + ], +}
diff --git a/src/cobalt/script/v8c/v8c_engine.cc b/src/cobalt/script/v8c/v8c_engine.cc new file mode 100644 index 0000000..2c928bc --- /dev/null +++ b/src/cobalt/script/v8c/v8c_engine.cc
@@ -0,0 +1,147 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cobalt/script/v8c/v8c_engine.h" + +#include <algorithm> +#include <string> + +#include "base/debug/trace_event.h" +#include "base/logging.h" +#include "base/message_loop.h" +#include "cobalt/base/c_val.h" +#include "cobalt/browser/stack_size_constants.h" +#include "cobalt/script/v8c/v8c_global_environment.h" +#include "starboard/once.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8.h" + +namespace cobalt { +namespace script { + +namespace v8c { +namespace { + +// Trigger garbage collection this many seconds after the last one. +const int kGarbageCollectionIntervalSeconds = 60; + +SbOnceControl g_js_init_once_control = SB_ONCE_INITIALIZER; +v8::Platform* g_platform = nullptr; +v8::ArrayBuffer::Allocator* g_array_buffer_allocator = nullptr; + +void ShutDown(void*) { + v8::V8::Dispose(); + v8::V8::ShutdownPlatform(); + + DCHECK(g_platform); + delete g_platform; + g_platform = nullptr; + + DCHECK(g_array_buffer_allocator); + delete g_array_buffer_allocator; + g_array_buffer_allocator = nullptr; +} + +void InitializeAndRegisterShutDownOnce() { + // TODO: Initialize V8 ICU stuff here as well. + g_platform = v8::platform::CreateDefaultPlatform(); + v8::V8::InitializePlatform(g_platform); + v8::V8::Initialize(); + g_array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); + + base::AtExitManager::RegisterCallback(ShutDown, nullptr); +} + +} // namespace + +V8cEngine::V8cEngine(const Options& options) + : accumulated_extra_memory_cost_(0), options_(options) { + TRACE_EVENT0("cobalt::script", "V8cEngine::V8cEngine()"); + SbOnce(&g_js_init_once_control, InitializeAndRegisterShutDownOnce); + DCHECK(g_platform); + DCHECK(g_array_buffer_allocator); + + v8::Isolate::CreateParams params; + params.array_buffer_allocator = g_array_buffer_allocator; + + isolate_ = v8::Isolate::New(params); + CHECK(isolate_); + + if (MessageLoop::current()) { + gc_timer_.Start( + FROM_HERE, + base::TimeDelta::FromSeconds(kGarbageCollectionIntervalSeconds), this, + &V8cEngine::TimerGarbageCollect); + } +} + +V8cEngine::~V8cEngine() { + DCHECK(thread_checker_.CalledOnValidThread()); + isolate_->Dispose(); + isolate_ = nullptr; +} + +scoped_refptr<GlobalEnvironment> V8cEngine::CreateGlobalEnvironment() { + TRACE_EVENT0("cobalt::script", "V8cEngine::CreateGlobalEnvironment()"); + DCHECK(thread_checker_.CalledOnValidThread()); + return new V8cGlobalEnvironment(isolate_); +} + +void V8cEngine::CollectGarbage() { + TRACE_EVENT0("cobalt::script", "V8cEngine::CollectGarbage()"); + DCHECK(thread_checker_.CalledOnValidThread()); + NOTIMPLEMENTED(); +} + +void V8cEngine::ReportExtraMemoryCost(size_t bytes) { + DCHECK(thread_checker_.CalledOnValidThread()); + accumulated_extra_memory_cost_ += bytes; + + const bool do_collect_garbage = + accumulated_extra_memory_cost_ > options_.gc_threshold_bytes; + if (do_collect_garbage) { + accumulated_extra_memory_cost_ = 0; + CollectGarbage(); + } +} + +bool V8cEngine::RegisterErrorHandler(JavaScriptEngine::ErrorHandler handler) { + error_handler_ = handler; + return true; +} + +void V8cEngine::SetGcThreshold(int64_t bytes) { NOTIMPLEMENTED(); } + +void V8cEngine::TimerGarbageCollect() { + TRACE_EVENT0("cobalt::script", "V8cEngine::TimerGarbageCollect()"); + CollectGarbage(); +} + +} // namespace v8c + +// static +scoped_ptr<JavaScriptEngine> JavaScriptEngine::CreateEngine( + const JavaScriptEngine::Options& options) { + TRACE_EVENT0("cobalt::script", "JavaScriptEngine::CreateEngine()"); + return make_scoped_ptr<JavaScriptEngine>(new v8c::V8cEngine(options)); +} + +// static +size_t JavaScriptEngine::UpdateMemoryStatsAndReturnReserved() { + NOTIMPLEMENTED(); + return 0; +} + +} // namespace script +} // namespace cobalt
diff --git a/src/cobalt/script/v8c/v8c_engine.h b/src/cobalt/script/v8c/v8c_engine.h new file mode 100644 index 0000000..2962efb --- /dev/null +++ b/src/cobalt/script/v8c/v8c_engine.h
@@ -0,0 +1,67 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COBALT_SCRIPT_V8C_V8C_ENGINE_H_ +#define COBALT_SCRIPT_V8C_V8C_ENGINE_H_ + +#include <vector> + +#include "base/threading/thread_checker.h" +#include "base/timer.h" +#include "cobalt/script/javascript_engine.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8.h" + +namespace cobalt { +namespace script { +namespace v8c { + +class V8cEngine : public JavaScriptEngine { + public: + explicit V8cEngine(const Options& options); + ~V8cEngine() override; + + scoped_refptr<GlobalEnvironment> CreateGlobalEnvironment() override; + void CollectGarbage() override; + void ReportExtraMemoryCost(size_t bytes) override; + bool RegisterErrorHandler(JavaScriptEngine::ErrorHandler handler) override; + void SetGcThreshold(int64_t bytes) override; + + v8::Isolate* isolate() const { return isolate_; } + + private: + void TimerGarbageCollect(); + + base::ThreadChecker thread_checker_; + + // An isolated instance of the V8 engine. + v8::Isolate* isolate_; + + // The amount of externally allocated memory since last forced GC. + size_t accumulated_extra_memory_cost_; + + // Used to trigger a garbage collection periodically. + base::RepeatingTimer<V8cEngine> gc_timer_; + + // Used to handle javascript errors. + ErrorHandler error_handler_; + + JavaScriptEngine::Options options_; +}; + +} // namespace v8c +} // namespace script +} // namespace cobalt + +#endif // COBALT_SCRIPT_V8C_V8C_ENGINE_H_
diff --git a/src/cobalt/script/v8c/v8c_global_environment.cc b/src/cobalt/script/v8c/v8c_global_environment.cc new file mode 100644 index 0000000..a4d1c6f --- /dev/null +++ b/src/cobalt/script/v8c/v8c_global_environment.cc
@@ -0,0 +1,175 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cobalt/script/v8c/v8c_global_environment.h" + +#include <algorithm> +#include <utility> + +#include "base/lazy_instance.h" +#include "base/stringprintf.h" +#include "cobalt/base/polymorphic_downcast.h" +#include "cobalt/script/v8c/v8c_source_code.h" +#include "nb/memory_scope.h" + +namespace cobalt { +namespace script { +namespace v8c { + +V8cGlobalEnvironment::V8cGlobalEnvironment(v8::Isolate* isolate) + : garbage_collection_count_(0), + environment_settings_(nullptr), + last_error_message_(nullptr), + eval_enabled_(false), + isolate_(isolate) { + TRACK_MEMORY_SCOPE("Javascript"); + v8::Isolate::Scope isolate_scope(isolate_); + v8::HandleScope handle_scope(isolate_); + v8::Local<v8::ObjectTemplate> global_object_template; + v8::Local<v8::Context> context = + v8::Context::New(isolate_, nullptr, global_object_template); + context_.Reset(isolate_, context); +} + +V8cGlobalEnvironment::~V8cGlobalEnvironment() { + DCHECK(thread_checker_.CalledOnValidThread()); +} + +void V8cGlobalEnvironment::CreateGlobalObject() { + TRACK_MEMORY_SCOPE("Javascript"); + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO: Global object creation happens with context creation in V8. + // Strongly consider removing this from the interface. + EvaluateAutomatics(); +} + +bool V8cGlobalEnvironment::EvaluateScript( + const scoped_refptr<SourceCode>& source_code, + std::string* out_result_utf8) { + TRACK_MEMORY_SCOPE("Javascript"); + DCHECK(thread_checker_.CalledOnValidThread()); + + v8::Isolate::Scope isolate_scope(isolate_); + v8::HandleScope handle_scope(isolate_); + v8::Local<v8::Context> context = context_.Get(isolate_); + v8::Context::Scope scope(context); + + v8::TryCatch try_catch(isolate_); + // TODO: Also pass in a |v8::ScriptOrigin|. + V8cSourceCode* v8c_source_code = + base::polymorphic_downcast<V8cSourceCode*>(source_code.get()); + v8::Local<v8::String> source = + v8::String::NewFromUtf8(isolate_, v8c_source_code->source_utf8().c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked(); + + auto maybe_script = v8::Script::Compile(context, source); + v8::Local<v8::Script> script; + if (!maybe_script.ToLocal(&script)) { + return false; + } + + auto maybe_result = script->Run(context); + v8::Local<v8::Value> result; + if (!maybe_result.ToLocal(&result)) { + return false; + } + + if (out_result_utf8) { + *out_result_utf8 = *v8::String::Utf8Value(isolate_, result); + } + + return true; +} + +bool V8cGlobalEnvironment::EvaluateScript( + const scoped_refptr<SourceCode>& source_code, + const scoped_refptr<Wrappable>& owning_object, + base::optional<OpaqueHandleHolder::Reference>* out_opaque_handle) { + TRACK_MEMORY_SCOPE("Javascript"); + DCHECK(thread_checker_.CalledOnValidThread()); + // TODO: Implement this once we have |V8cObjectHandleHolder|. + NOTIMPLEMENTED(); + return false; +} + +std::vector<StackFrame> V8cGlobalEnvironment::GetStackTrace(int max_frames) { + DCHECK(thread_checker_.CalledOnValidThread()); + NOTIMPLEMENTED(); + return {}; +} + +void V8cGlobalEnvironment::PreventGarbageCollection( + const scoped_refptr<Wrappable>& wrappable) { + DCHECK(thread_checker_.CalledOnValidThread()); + NOTIMPLEMENTED(); +} + +void V8cGlobalEnvironment::AllowGarbageCollection( + const scoped_refptr<Wrappable>& wrappable) { + TRACK_MEMORY_SCOPE("Javascript"); + DCHECK(thread_checker_.CalledOnValidThread()); + NOTIMPLEMENTED(); +} + +void V8cGlobalEnvironment::DisableEval(const std::string& message) { + DCHECK(thread_checker_.CalledOnValidThread()); + eval_disabled_message_.emplace(message); + eval_enabled_ = false; +} + +void V8cGlobalEnvironment::EnableEval() { + DCHECK(thread_checker_.CalledOnValidThread()); + eval_disabled_message_ = base::nullopt; + eval_enabled_ = true; +} + +void V8cGlobalEnvironment::DisableJit() { + DCHECK(thread_checker_.CalledOnValidThread()); + SB_DLOG(INFO) + << "V8 can only be run with JIT enabled, ignoring |DisableJit| call."; +} + +void V8cGlobalEnvironment::SetReportEvalCallback( + const base::Closure& report_eval) { + DCHECK(thread_checker_.CalledOnValidThread()); + report_eval_ = report_eval; +} + +void V8cGlobalEnvironment::SetReportErrorCallback( + const ReportErrorCallback& report_error_callback) { + DCHECK(thread_checker_.CalledOnValidThread()); + report_error_callback_ = report_error_callback; +} + +void V8cGlobalEnvironment::Bind(const std::string& identifier, + const scoped_refptr<Wrappable>& impl) { + TRACK_MEMORY_SCOPE("Javascript"); + NOTIMPLEMENTED(); +} + +ScriptValueFactory* V8cGlobalEnvironment::script_value_factory() { + NOTIMPLEMENTED(); + return nullptr; +} + +void V8cGlobalEnvironment::EvaluateAutomatics() { + // TODO: Maybe add fetch, stream, and promise polyfills. Investigate what + // V8 has to natively offer first. + NOTIMPLEMENTED(); +} + +} // namespace v8c +} // namespace script +} // namespace cobalt
diff --git a/src/cobalt/script/v8c/v8c_global_environment.h b/src/cobalt/script/v8c/v8c_global_environment.h new file mode 100644 index 0000000..d60637f --- /dev/null +++ b/src/cobalt/script/v8c/v8c_global_environment.h
@@ -0,0 +1,113 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COBALT_SCRIPT_V8C_V8C_GLOBAL_ENVIRONMENT_H_ +#define COBALT_SCRIPT_V8C_V8C_GLOBAL_ENVIRONMENT_H_ + +#include <string> +#include <vector> + +#include "base/hash_tables.h" +#include "base/logging.h" +#include "base/optional.h" +#include "base/stl_util.h" +#include "base/threading/thread_checker.h" +#include "cobalt/script/global_environment.h" +#include "cobalt/script/javascript_engine.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8.h" + +namespace cobalt { +namespace script { +namespace v8c { + +class V8cScriptValueFactory; +class ReferencedObjectMap; +class WeakHandle; + +// Manages a handle to a JavaScript engine's global object. The lifetime of +// the global object is not necessarily tied to the lifetime of the proxy. +class V8cGlobalEnvironment : public GlobalEnvironment, + public Wrappable::CachedWrapperAccessor { + public: + explicit V8cGlobalEnvironment(v8::Isolate* isolate); + ~V8cGlobalEnvironment() override; + + void CreateGlobalObject() override; + + bool EvaluateScript(const scoped_refptr<SourceCode>& script, + std::string* out_result_utf8) override; + + bool EvaluateScript(const scoped_refptr<SourceCode>& script_utf8, + const scoped_refptr<Wrappable>& owning_object, + base::optional<OpaqueHandleHolder::Reference>* + out_opaque_handle) override; + + std::vector<StackFrame> GetStackTrace(int max_frames = 0) override; + + void PreventGarbageCollection( + const scoped_refptr<Wrappable>& wrappable) override; + + void AllowGarbageCollection( + const scoped_refptr<Wrappable>& wrappable) override; + + void DisableEval(const std::string& message) override; + + void EnableEval() override; + + void DisableJit() override; + + void SetReportEvalCallback(const base::Closure& report_eval) override; + + void SetReportErrorCallback( + const ReportErrorCallback& report_error_callback) override; + + void Bind(const std::string& identifier, + const scoped_refptr<Wrappable>& impl) override; + + ScriptValueFactory* script_value_factory() override; + + // Evaluates any automatically included Javascript for the environment. + void EvaluateAutomatics(); + + v8::Isolate* isolate() const { return isolate_; } + v8::Local<v8::Context> context() const { + return v8::Local<v8::Context>::New(isolate_, context_); + } + + private: + base::ThreadChecker thread_checker_; + v8::Isolate* isolate_; + v8::Global<v8::Context> context_; + int garbage_collection_count_; + + v8::Global<v8::Object> global_object_; + + EnvironmentSettings* environment_settings_; + + // If non-NULL, the error message from the ReportErrorHandler will get + // assigned to this instead of being printed. + std::string* last_error_message_; + + bool eval_enabled_; + base::optional<std::string> eval_disabled_message_; + base::Closure report_eval_; + ReportErrorCallback report_error_callback_; +}; + +} // namespace v8c +} // namespace script +} // namespace cobalt + +#endif // COBALT_SCRIPT_V8C_V8C_GLOBAL_ENVIRONMENT_H_
diff --git a/src/cobalt/script/v8c/v8c_source_code.cc b/src/cobalt/script/v8c/v8c_source_code.cc new file mode 100644 index 0000000..053da7f --- /dev/null +++ b/src/cobalt/script/v8c/v8c_source_code.cc
@@ -0,0 +1,27 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "cobalt/script/v8c/v8c_source_code.h" + +namespace cobalt { +namespace script { + +scoped_refptr<SourceCode> SourceCode::CreateSourceCode( + const std::string& script_utf8, + const base::SourceLocation& script_location) { + return new v8c::V8cSourceCode(script_utf8, script_location); +} + +} // namespace script +} // namespace cobalt
diff --git a/src/cobalt/script/v8c/v8c_source_code.h b/src/cobalt/script/v8c/v8c_source_code.h new file mode 100644 index 0000000..f014afa --- /dev/null +++ b/src/cobalt/script/v8c/v8c_source_code.h
@@ -0,0 +1,47 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COBALT_SCRIPT_V8C_V8C_SOURCE_CODE_H_ +#define COBALT_SCRIPT_V8C_V8C_SOURCE_CODE_H_ + +#include <string> + +#include "cobalt/base/source_location.h" +#include "cobalt/script/source_code.h" + +namespace cobalt { +namespace script { +namespace v8c { + +// TODO: Consider pre-compiling scripts here. +// TODO: Also separately consider making this class entirely non-engine +// specific if no engine is going to do anything special with it. +class V8cSourceCode : public SourceCode { + public: + V8cSourceCode(const std::string& source_utf8, + const base::SourceLocation& source_location) + : source_utf8_(source_utf8), location_(source_location) {} + const std::string& source_utf8() const { return source_utf8_; } + const base::SourceLocation& location() const { return location_; } + + private: + std::string source_utf8_; + base::SourceLocation location_; +}; + +} // namespace v8c +} // namespace script +} // namespace cobalt + +#endif // COBALT_SCRIPT_V8C_V8C_SOURCE_CODE_H_
diff --git a/src/cobalt/script/v8c/v8c_variables.gypi b/src/cobalt/script/v8c/v8c_variables.gypi new file mode 100644 index 0000000..4348bd4 --- /dev/null +++ b/src/cobalt/script/v8c/v8c_variables.gypi
@@ -0,0 +1,51 @@ +# Copyright 2017 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + 'variables': { + 'conditions': [ + ['javascript_engine == "v8"', { + 'generated_bindings_prefix': 'v8c', + 'engine_include_dirs': [], + 'engine_dependencies': [ + '<(DEPTH)/v8/src/v8.gyp:v8', + '<(DEPTH)/v8/src/v8.gyp:v8_libplatform', + ], + 'engine_defines': [], + 'engine_templates_dir': [ + '<(DEPTH)/cobalt/bindings/v8c/templates', + ], + 'engine_template_files': [ + '<(DEPTH)/cobalt/bindings/v8c/templates/callback-interface.cc.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/callback-interface.h.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/dictionary-conversion.cc.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/enumeration-conversion.cc.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/generated-types.h.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/interface.cc.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/interface.h.template', + '<(DEPTH)/cobalt/bindings/v8c/templates/macros.cc.template', + ], + 'engine_bindings_scripts': [ + '<(DEPTH)/cobalt/bindings/v8c/code_generator_v8c.py', + '<(DEPTH)/cobalt/bindings/v8c/idl_compiler_v8c.py', + '<(DEPTH)/cobalt/bindings/v8c/generate_conversion_header_v8c.py', + ], + 'engine_idl_compiler': + '<(DEPTH)/cobalt/bindings/v8c/idl_compiler_v8c.py', + 'engine_conversion_header_generator_script': + '<(DEPTH)/cobalt/bindings/v8c/generate_conversion_header_v8c.py', + }], + ], + }, +}
diff --git a/src/cobalt/storage/savegame_starboard.cc b/src/cobalt/storage/savegame_starboard.cc index da62a3b..769d0b4 100644 --- a/src/cobalt/storage/savegame_starboard.cc +++ b/src/cobalt/storage/savegame_starboard.cc
@@ -71,13 +71,13 @@ scoped_ptr<starboard::StorageRecord> CreateRecord( const base::optional<std::string>& id) { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 if (id) { return make_scoped_ptr(new starboard::StorageRecord(id->c_str())); } -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 UNREFERENCED_PARAMETER(id); -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 return make_scoped_ptr(new starboard::StorageRecord()); }
diff --git a/src/cobalt/system_window/input_event.h b/src/cobalt/system_window/input_event.h index 2235657..12eae54 100644 --- a/src/cobalt/system_window/input_event.h +++ b/src/cobalt/system_window/input_event.h
@@ -55,7 +55,7 @@ InputEvent(Type type, int device_id, int key_code, uint32 modifiers, bool is_repeat, const math::PointF& position = math::PointF(), const math::PointF& delta = math::PointF() -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 , float pressure = 0, const math::PointF& size = math::PointF(), const math::PointF& tilt = math::PointF() @@ -68,7 +68,7 @@ is_repeat_(is_repeat), position_(position), delta_(delta) -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 , pressure_(pressure), size_(size), @@ -84,7 +84,7 @@ bool is_repeat() const { return is_repeat_; } const math::PointF& position() const { return position_; } const math::PointF& delta() const { return delta_; } -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 float pressure() const { return pressure_; } const math::PointF& size() const { return size_; } const math::PointF& tilt() const { return tilt_; } @@ -100,7 +100,7 @@ bool is_repeat_; math::PointF position_; math::PointF delta_; -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 float pressure_; math::PointF size_; math::PointF tilt_;
diff --git a/src/cobalt/system_window/system_window.cc b/src/cobalt/system_window/system_window.cc index 1e2c38f..7b2529e 100644 --- a/src/cobalt/system_window/system_window.cc +++ b/src/cobalt/system_window/system_window.cc
@@ -102,7 +102,7 @@ // Starboard handily uses the Microsoft key mapping, which is also what Cobalt // uses. int key_code = static_cast<int>(data.key); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 float pressure = data.pressure; uint32 modifiers = data.key_modifiers; if (((data.device_type == kSbInputDeviceTypeTouchPad) || @@ -159,7 +159,7 @@ DispatchInputEvent(data, input_event_type, false /* is_repeat */); break; } -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 case kSbInputEventTypeWheel: { DispatchInputEvent(data, InputEvent::kWheel, false /* is_repeat */); break;
diff --git a/src/cobalt/webdriver/element_driver.cc b/src/cobalt/webdriver/element_driver.cc index b53ae7b..c8dbfd8 100644 --- a/src/cobalt/webdriver/element_driver.cc +++ b/src/cobalt/webdriver/element_driver.cc
@@ -242,7 +242,7 @@ event.set_pointer_type("mouse"); event.set_pointer_id(kWebDriverMousePointerId); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 event.set_width(0.0f); event.set_height(0.0f); event.set_pressure(0.0f); @@ -256,13 +256,13 @@ pointer_event_injector_.Run(scoped_refptr<dom::Element>(), base::Tokens::pointermove(), event); event.set_buttons(1); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 event.set_pressure(0.5f); #endif pointer_event_injector_.Run(scoped_refptr<dom::Element>(), base::Tokens::pointerdown(), event); event.set_buttons(0); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 event.set_pressure(0.0f); #endif pointer_event_injector_.Run(scoped_refptr<dom::Element>(),
diff --git a/src/cobalt/webdriver/window_driver.cc b/src/cobalt/webdriver/window_driver.cc index 8685d52..fac224c 100644 --- a/src/cobalt/webdriver/window_driver.cc +++ b/src/cobalt/webdriver/window_driver.cc
@@ -530,7 +530,7 @@ event->set_pointer_type("mouse"); event->set_pointer_id(kWebDriverMousePointerId); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 event->set_width(0.0f); event->set_height(0.0f); event->set_pressure(pointer_buttons_ ? 0.5f : 0.0f);
diff --git a/src/starboard/CHANGELOG.md b/src/starboard/CHANGELOG.md index 4b010c4..4bf24e5 100644 --- a/src/starboard/CHANGELOG.md +++ b/src/starboard/CHANGELOG.md
@@ -71,6 +71,10 @@ * Closed Caption key * Application launch key * Channel Up/Down keys + * Info key + * Guide key + * Last/Previous Channel key + * Media audio track select key ### `kSbEventTypeLowMemory`
diff --git a/src/starboard/configuration.h b/src/starboard/configuration.h index b9a1f5c..a8548ea 100644 --- a/src/starboard/configuration.h +++ b/src/starboard/configuration.h
@@ -68,23 +68,7 @@ // #define SB_MY_EXPERIMENTAL_FEATURE_VERSION SB_EXPERIMENTAL_API_VERSION // --- Release Candidate Feature Defines ------------------------------------- -#define SB_DECODE_TARGET_PLANE_FORMAT_VERSION 7 - -#define SB_POINTER_INPUT_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER SB_RELEASE_CANDIDATE_API_VERSION -#define SB_TIME_ZONE_FLEXIBLE_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_DECODE_TARGET_PLANES_FOR_FORMAT SB_RELEASE_CANDIDATE_API_VERSION -#define SB_PRELOAD_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_PLATFORM_ERROR_CLEANUP_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION \ - SB_RELEASE_CANDIDATE_API_VERSION -#define SB_NEW_KEYCODES_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_LOW_MEMORY_EVENT_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION -#define SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION \ - SB_RELEASE_CANDIDATE_API_VERSION -#define SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION \ - SB_RELEASE_CANDIDATE_API_VERSION -#define SB_STORAGE_NAMES_API_VERSION SB_RELEASE_CANDIDATE_API_VERSION +#define SB_DECODE_TARGET_PLANE_FORMAT_VERSION SB_RELEASE_CANDIDATE_API_VERSION // --- Common Detected Features ----------------------------------------------
diff --git a/src/starboard/decode_target.h b/src/starboard/decode_target.h index 40a680f..2bb46e5 100644 --- a/src/starboard/decode_target.h +++ b/src/starboard/decode_target.h
@@ -135,7 +135,7 @@ // A decoder target format consisting of Y, U, and V planes, in that order. kSbDecodeTargetFormat3PlaneYUVI420, -#if SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 // A decoder target format consisting of a single plane with pixels layed out // in the format UYVY. Since there are two Y values per sample, but only one // U value and only one V value, horizontally the Y resolution is twice the @@ -146,7 +146,7 @@ // the number of UYVY tuples per row (e.g. the u/v width resolution). // Content region left/right should be specified in u/v width resolution. kSbDecodeTargetFormat1PlaneUYVY, -#endif // SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION +#endif // An invalid decode target format. kSbDecodeTargetFormatInvalid, @@ -251,7 +251,7 @@ // that it be set to something else like GL_TEXTURE_EXTERNAL_OES. uint32_t gl_texture_target; -#if SB_API_VERSION >= SB_DECODE_TARGET_FORMAT_VERSION +#if SB_API_VERSION >= SB_DECODE_TARGET_PLANE_FORMAT_VERSION // For kSbDecodeTargetFormat2PlaneYUVNV12 planes: the format of the // texture. Usually, for the luma plane, this is either GL_ALPHA or // GL_RED_EXT. For the chroma plane, this is usually GL_LUMINANCE_ALPHA @@ -260,7 +260,7 @@ uint32_t gl_texture_format; #endif // SB_API_VERSION >= SB_DECODE_TARGET_NV12_R_RG_API_VERSION -#endif // SB_HAS(BLITTER) +#endif // SB_HAS(BLITTER) // The width of the texture/surface for this particular plane. int width; @@ -323,14 +323,12 @@ return format != kSbDecodeTargetFormatInvalid; } -#if SB_API_VERSION >= SB_DECODE_TARGET_PLANES_FOR_FORMAT +#if SB_API_VERSION >= 6 static SB_C_INLINE int SbDecodeTargetNumberOfPlanesForFormat( SbDecodeTargetFormat format) { switch (format) { case kSbDecodeTargetFormat1PlaneRGBA: -#if SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION case kSbDecodeTargetFormat1PlaneUYVY: -#endif // SB_API_VERSION >= SB_DECODE_TARGET_UYVY_SUPPORT_API_VERSION return 1; case kSbDecodeTargetFormat1PlaneBGRA: return 1; @@ -343,7 +341,7 @@ return 0; } } -#endif // SB_API_VERSION >= SB_DECODE_TARGET_PLANES_FOR_FORMAT +#endif // SB_API_VERSION >= 6 // Returns ownership of |decode_target| to the Starboard implementation. // This function will likely result in the destruction of the SbDecodeTarget and
diff --git a/src/starboard/drm.h b/src/starboard/drm.h index 8149cd8..4ce3df8 100644 --- a/src/starboard/drm.h +++ b/src/starboard/drm.h
@@ -52,14 +52,14 @@ int32_t encrypted_byte_count; } SbDrmSubSampleMapping; -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 typedef struct SbDrmKeyId { // The ID of the license (or key) required to decrypt this sample. For // PlayReady, this is the license GUID in packed little-endian binary form. uint8_t identifier[16]; int identifier_size; } SbDrmKeyId; -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 // All the optional information needed per sample for encrypted samples. typedef struct SbDrmSampleInfo { @@ -121,7 +121,7 @@ // A callback for notifications that the status of one or more keys in a session // has been changed. All keys of the session and their new status will be // passed along. Any keys not in the list is considered as deleted. -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 typedef void (*SbDrmSessionKeyStatusesChangedFunc)( SbDrmSystem drm_system, void* context, @@ -130,7 +130,7 @@ int number_of_keys, const SbDrmKeyId* key_ids, const SbDrmKeyStatus* key_statuses); -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6 // --- Constants ------------------------------------------------------------- @@ -171,7 +171,7 @@ // SbDrmGenerateSessionUpdateRequest() is called. // |session_updated_callback|: A function that is called every time after // SbDrmUpdateSession() is called. -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 SB_EXPORT SbDrmSystem SbDrmCreateSystem( const char* key_system, @@ -180,7 +180,7 @@ SbDrmSessionUpdatedFunc session_updated_callback, SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback); -#else // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#else // SB_API_VERSION >= 6 SB_EXPORT SbDrmSystem SbDrmCreateSystem(const char* key_system,
diff --git a/src/starboard/event.h b/src/starboard/event.h index 7bfca2c..cd01304 100644 --- a/src/starboard/event.h +++ b/src/starboard/event.h
@@ -95,7 +95,7 @@ // system. Each event is accompanied by a void* data argument, and each event // must define the type of the value pointed to by that data argument, if any. typedef enum SbEventType { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 // Applications should perform initialization and prepare to react to // subsequent events, but must not initialize any graphics resources (through // GL or SbBlitter). The intent of this event is to allow the application to @@ -112,7 +112,7 @@ // call SbSystemRequestSuspend() when they are done preloading to request // this. kSbEventTypePreload, -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 // The first event that an application receives on startup when starting // normally (i.e. not being preloaded). Applications should perform @@ -204,14 +204,14 @@ // new settings. kSbEventTypeAccessiblitySettingsChanged, -#if SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#if SB_API_VERSION >= 6 // An optional event that platforms may send to indicate that the application // may soon be terminated (or crash) due to low memory availability. The // application may respond by reducing memory consumption by running a Garbage // Collection, flushing caches, or something similar. There is no requirement // to respond to or handle this event, it is only advisory. kSbEventTypeLowMemory, -#endif // SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#endif // SB_API_VERSION >= 6 } SbEventType; // Structure representing a Starboard event and its data.
diff --git a/src/starboard/examples/window/main.cc b/src/starboard/examples/window/main.cc index b508e7d..20b0341 100644 --- a/src/starboard/examples/window/main.cc +++ b/src/starboard/examples/window/main.cc
@@ -32,7 +32,7 @@ void SbEventHandle(const SbEvent* event) { switch (event->type) { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypePreload: { SB_LOG(INFO) << "PRELOAD"; SbEventStartData* data = static_cast<SbEventStartData*>(event->data);
diff --git a/src/starboard/input.h b/src/starboard/input.h index c3a7dbf..a32a05a 100644 --- a/src/starboard/input.h +++ b/src/starboard/input.h
@@ -121,7 +121,7 @@ // event is sent when the key or button being pressed is released. kSbInputEventTypeUnpress, -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 // Wheel movement. Provides relative movements of the |Mouse| wheel. kSbInputEventTypeWheel, #endif @@ -176,7 +176,7 @@ // not applicable. SbInputVector delta; -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 // The normalized pressure of the pointer input in the range of [0,1], where 0 // and 1 represent the minimum and maximum pressure the hardware is capable of // detecting, respectively. Use NaN for devices that do not report pressure.
diff --git a/src/starboard/key.h b/src/starboard/key.h index 73a1cb6..34d2f19 100644 --- a/src/starboard/key.h +++ b/src/starboard/key.h
@@ -208,7 +208,9 @@ kSbKeyMediaRewind = 0xE3, kSbKeyMediaFastForward = 0xE4, -#if SB_API_VERSION >= SB_NEW_KEYCODES_API_VERSION +#if SB_API_VERSION >= 6 + // Key codes from the DTV Application Software Environment, + // http://www.atsc.org/wp-content/uploads/2015/03/a_100_4.pdf kSbKeyRed = 0x193, kSbKeyGreen = 0x194, kSbKeyYellow = 0x195, @@ -219,9 +221,22 @@ kSbKeySubtitle = 0x1CC, kSbKeyClosedCaption = kSbKeySubtitle, + kSbKeyInfo = 0x1C9, + kSbKeyGuide = 0x1CA, + + // Key codes from OCAP, + // https://apps.cablelabs.com/specification/opencable-application-platform-ocap/ + kSbKeyLast = 0x25f, + kSbKeyPreviousChannel = kSbKeyLast, + + // Custom Starboard-defined keycodes. + // A button that will directly launch the current application. kSbKeyLaunchThisApplication = 0x3000, -#endif // SB_API_VERSION >= SB_NEW_KEYCODES_API_VERSION + + // A button that will switch between different available audio tracks. + kSbKeyMediaAudioTrack = 0x3001, +#endif // SB_API_VERSION >= 6 // Mouse buttons, starting with the left mouse button. kSbKeyMouse1 = 0x7000, @@ -296,7 +311,7 @@ kSbKeyModifiersCtrl = 1 << 1, kSbKeyModifiersMeta = 1 << 2, kSbKeyModifiersShift = 1 << 3, -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 kSbKeyModifiersPointerButtonLeft = 1 << 4, kSbKeyModifiersPointerButtonRight = 1 << 5, kSbKeyModifiersPointerButtonMiddle = 1 << 6,
diff --git a/src/starboard/media.h b/src/starboard/media.h index a01b109..2673bcf 100644 --- a/src/starboard/media.h +++ b/src/starboard/media.h
@@ -462,11 +462,11 @@ // The AudioSpecificConfig, as specified in ISO/IEC-14496-3, section 1.6.2.1: // http://read.pudn.com/downloads98/doc/comm/401153/14496/ISO_IEC_14496-3%20Part%203%20Audio/C036083E_SUB1.PDF -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 const void* audio_specific_config; -#else // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#else // SB_API_VERSION >= 6 int8_t audio_specific_config[8]; -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 } SbMediaAudioHeader; // --- Constants -------------------------------------------------------------
diff --git a/src/starboard/nplb/key_test.cc b/src/starboard/nplb/key_test.cc index f3644cd..784f602 100644 --- a/src/starboard/nplb/key_test.cc +++ b/src/starboard/nplb/key_test.cc
@@ -24,7 +24,7 @@ EXPECT_NE(kSbKeyUnknown, kSbKeyMediaRewind); EXPECT_NE(kSbKeyUnknown, kSbKeyMediaFastForward); -#if SB_API_VERSION >= SB_NEW_KEYCODES_API_VERSION +#if SB_API_VERSION >= 6 EXPECT_NE(kSbKeyUnknown, kSbKeyRed); EXPECT_NE(kSbKeyUnknown, kSbKeyGreen); EXPECT_NE(kSbKeyUnknown, kSbKeyYellow); @@ -33,8 +33,13 @@ EXPECT_NE(kSbKeyUnknown, kSbKeyChannelUp); EXPECT_NE(kSbKeyUnknown, kSbKeyChannelDown); EXPECT_NE(kSbKeyUnknown, kSbKeyClosedCaption); + EXPECT_NE(kSbKeyUnknown, kSbKeyInfo); + EXPECT_NE(kSbKeyUnknown, kSbKeyGuide); + EXPECT_NE(kSbKeyUnknown, kSbKeyLast); + EXPECT_NE(kSbKeyUnknown, kSbKeyPreviousChannel); EXPECT_NE(kSbKeyUnknown, kSbKeyLaunchThisApplication); -#endif // SB_API_VERSION >= SB_NEW_KEYCODES_API_VERSION + EXPECT_NE(kSbKeyUnknown, kSbKeyMediaAudioTrack); +#endif // SB_API_VERSION >= 6 } } // namespace
diff --git a/src/starboard/nplb/player_create_test.cc b/src/starboard/nplb/player_create_test.cc index 9172d45..f9cbe22 100644 --- a/src/starboard/nplb/player_create_test.cc +++ b/src/starboard/nplb/player_create_test.cc
@@ -50,9 +50,9 @@ audio_header.block_alignment = 4; audio_header.bits_per_sample = 32; audio_header.audio_specific_config_size = 0; -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 audio_header.audio_specific_config = NULL; -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 audio_header.average_bytes_per_second = audio_header.samples_per_second * audio_header.number_of_channels * audio_header.bits_per_sample / 8;
diff --git a/src/starboard/nplb/storage_delete_record_test.cc b/src/starboard/nplb/storage_delete_record_test.cc index ef0fc73..ef3db9a 100644 --- a/src/starboard/nplb/storage_delete_record_test.cc +++ b/src/starboard/nplb/storage_delete_record_test.cc
@@ -23,7 +23,7 @@ namespace nplb { namespace { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 TEST(SbStorageDeleteRecordTest, RainyDayInvalidUserValidName) { EXPECT_FALSE(SbStorageDeleteRecord( @@ -34,13 +34,13 @@ EXPECT_FALSE(SbStorageDeleteRecord(kSbUserInvalid, NULL)); } -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 TEST(SbStorageDeleteRecordTest, RainyDayInvalidUser) { EXPECT_FALSE(SbStorageDeleteRecord(kSbUserInvalid)); } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 } // namespace } // namespace nplb
diff --git a/src/starboard/nplb/storage_helpers.h b/src/starboard/nplb/storage_helpers.h index c587203..867d3b0 100644 --- a/src/starboard/nplb/storage_helpers.h +++ b/src/starboard/nplb/storage_helpers.h
@@ -28,32 +28,32 @@ // Deletes the storage for the current user. static SB_C_INLINE void ClearStorageRecord() { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 SbStorageDeleteRecord(SbUserGetCurrent(), NULL); -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 SbStorageDeleteRecord(SbUserGetCurrent()); -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 } -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 // Deletes the named storage record for the current user. static SB_C_INLINE void ClearStorageRecord(const char* name) { SbStorageDeleteRecord(SbUserGetCurrent(), name); } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 // Opens the storage record for the current user, validating that it is valid. static SB_C_INLINE SbStorageRecord OpenStorageRecord() { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent(), NULL); -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent()); -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 // Opens the named storage record for the current user, validating that it is // valid. static SB_C_INLINE SbStorageRecord OpenStorageRecord(const char* name) { @@ -61,7 +61,7 @@ EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 // Writes a standard pattern of |size| bytes into the given open storage // |record|.
diff --git a/src/starboard/nplb/storage_open_record_test.cc b/src/starboard/nplb/storage_open_record_test.cc index c935e4a..5526451 100644 --- a/src/starboard/nplb/storage_open_record_test.cc +++ b/src/starboard/nplb/storage_open_record_test.cc
@@ -23,7 +23,7 @@ namespace nplb { namespace { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 TEST(SbStorageOpenRecordTest, RainyDayInvalidUserValidName) { EXPECT_FALSE(SbStorageIsValidRecord(SbStorageOpenRecord( @@ -35,13 +35,13 @@ SbStorageIsValidRecord(SbStorageOpenRecord(kSbUserInvalid, NULL))); } -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 TEST(SbStorageOpenRecordTest, RainyDayInvalidUser) { EXPECT_FALSE(SbStorageIsValidRecord(SbStorageOpenRecord(kSbUserInvalid))); } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 } // namespace } // namespace nplb
diff --git a/src/starboard/nplb/storage_read_record_test.cc b/src/starboard/nplb/storage_read_record_test.cc index 336e716..d6e46c9 100644 --- a/src/starboard/nplb/storage_read_record_test.cc +++ b/src/starboard/nplb/storage_read_record_test.cc
@@ -54,7 +54,7 @@ EXPECT_TRUE(SbStorageCloseRecord(record)); } -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 TEST(SbStorageReadRecordTest, SunnyDayNamed) { int64_t pattern = 0; std::string name = ScopedRandomFile::MakeRandomFilename(); @@ -157,7 +157,7 @@ ClearStorageRecord(name2.c_str()); ClearStorageRecord(); } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 TEST(SbStorageReadRecordTest, SunnyDayNonexistant) { ClearStorageRecord();
diff --git a/src/starboard/nplb/time_zone_get_dst_name_test.cc b/src/starboard/nplb/time_zone_get_dst_name_test.cc index d2926b5..fb7f20b 100644 --- a/src/starboard/nplb/time_zone_get_dst_name_test.cc +++ b/src/starboard/nplb/time_zone_get_dst_name_test.cc
@@ -20,7 +20,7 @@ namespace nplb { namespace { -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 TEST(SbTimeZoneGetDstNameTest, IsKindOfSane) { const char* name = SbTimeZoneGetDstName(); @@ -35,7 +35,7 @@ EXPECT_GE(i, 3); EXPECT_LE(i, 5); } -#endif // SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#endif // SB_API_VERSION < 6 } // namespace } // namespace nplb
diff --git a/src/starboard/nplb/time_zone_get_name_test.cc b/src/starboard/nplb/time_zone_get_name_test.cc index 41b7d5e..32428ce 100644 --- a/src/starboard/nplb/time_zone_get_name_test.cc +++ b/src/starboard/nplb/time_zone_get_name_test.cc
@@ -34,12 +34,12 @@ // or "Pacific Standard Time" or like "America/Los_Angeles" EXPECT_GE(i, 3); -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 // Some, like WART for Western Argentina, are 4. // A very few, like ANAST, or CHAST is 5 // http://www.timeanddate.com/time/zones/ EXPECT_LE(i, 5); -#endif // SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#endif // SB_API_VERSION < 6 // On Linux, TZ=":Pacific/Chatham" is a good test of boundary conditions. // ":Pacific/Kiritimati" is the western-most timezone at UTC+14.
diff --git a/src/starboard/player.h b/src/starboard/player.h index 20b95a5..b97e354 100644 --- a/src/starboard/player.h +++ b/src/starboard/player.h
@@ -242,11 +242,11 @@ // |audio_header|: Note that the caller must provide a populated |audio_header| // if the audio codec is |kSbMediaAudioCodecAac|. Otherwise, |audio_header| // can be NULL. See media.h for the format of the |SbMediaAudioHeader| struct. -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 // Note that |audio_specific_config| is a pointer and the content it points to // is no longer valid after this function returns. The implementation has to // make a copy of the content if it is needed after the function returns. -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 // // |sample_deallocator_func|: If not |NULL|, the player calls this function // on an internal thread to free the sample buffers passed into @@ -377,13 +377,13 @@ SB_EXPORT void SbPlayerWriteSample( SbPlayer player, SbMediaType sample_type, -#if SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#if SB_API_VERSION >= 6 const void* const* sample_buffers, const int* sample_buffer_sizes, -#else // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#else // SB_API_VERSION >= 6 const void** sample_buffers, int* sample_buffer_sizes, -#endif // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#endif // SB_API_VERSION >= 6 int number_of_sample_buffers, SbMediaTime sample_pts, const SbMediaVideoSampleInfo* video_sample_info,
diff --git a/src/starboard/raspi/shared/application_dispmanx.h b/src/starboard/raspi/shared/application_dispmanx.h index 37f0b61..9f089da 100644 --- a/src/starboard/raspi/shared/application_dispmanx.h +++ b/src/starboard/raspi/shared/application_dispmanx.h
@@ -62,10 +62,10 @@ Event* WaitForSystemEventWithTimeout(SbTime duration) SB_OVERRIDE; void WakeSystemEventWait() SB_OVERRIDE; -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 bool IsStartImmediate() SB_OVERRIDE { return !HasPreloadSwitch(); } bool IsPreloadImmediate() SB_OVERRIDE { return HasPreloadSwitch(); } -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 private: // Returns whether DISPMANX has been initialized.
diff --git a/src/starboard/shared/directfb/application_directfb.h b/src/starboard/shared/directfb/application_directfb.h index 65f96c2..522bbc2 100644 --- a/src/starboard/shared/directfb/application_directfb.h +++ b/src/starboard/shared/directfb/application_directfb.h
@@ -44,10 +44,10 @@ IDirectFB* GetDirectFB(); SbWindow GetWindow(); -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 bool IsStartImmediate() SB_OVERRIDE { return !HasPreloadSwitch(); } bool IsPreloadImmediate() SB_OVERRIDE { return HasPreloadSwitch(); } -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 protected: // --- Application overrides ---
diff --git a/src/starboard/shared/linux/dev_input/dev_input.cc b/src/starboard/shared/linux/dev_input/dev_input.cc index 10393dd..f0155e7 100644 --- a/src/starboard/shared/linux/dev_input/dev_input.cc +++ b/src/starboard/shared/linux/dev_input/dev_input.cc
@@ -921,7 +921,7 @@ data->key_location = location; data->key_modifiers = modifiers; data->position = input_vector; -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 data->pressure = NAN; data->size = {NAN, NAN}; data->tilt = {NAN, NAN}; @@ -949,7 +949,7 @@ data->key_location = location; data->key_modifiers = modifiers; data->position = input_vector; -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 data->pressure = NAN; data->size = {NAN, NAN}; data->tilt = {NAN, NAN};
diff --git a/src/starboard/shared/posix/time_zone_get_dst_name.cc b/src/starboard/shared/posix/time_zone_get_dst_name.cc index 97683f9..cc437ae 100644 --- a/src/starboard/shared/posix/time_zone_get_dst_name.cc +++ b/src/starboard/shared/posix/time_zone_get_dst_name.cc
@@ -16,11 +16,11 @@ #include <time.h> -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 const char* SbTimeZoneGetDstName() { // TODO: Using tzname assumes that tzset() has been called at some // point. That should happen as part of Starboard's main loop initialization, // but that doesn't exist yet. return tzname[1]; } -#endif // SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#endif // SB_API_VERSION < 6
diff --git a/src/starboard/shared/starboard/application.cc b/src/starboard/shared/starboard/application.cc index 71235ab..926545b 100644 --- a/src/starboard/shared/starboard/application.cc +++ b/src/starboard/shared/starboard/application.cc
@@ -136,9 +136,9 @@ } void Application::InjectLowMemoryEvent() { -#if SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#if SB_API_VERSION >= 6 Inject(new Event(kSbEventTypeLowMemory, NULL, NULL)); -#endif // SB_API_VERSION >= SB_LOW_MEMORY_EVENT_API_VERSION +#endif // SB_API_VERSION >= 6 } SbEventId Application::Schedule(SbEventCallback callback, @@ -183,12 +183,12 @@ void Application::DispatchPreload() { SB_DCHECK(IsCurrentThread()); -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 SB_DCHECK(state_ == kStateUnstarted); DispatchAndDelete(CreateInitialEvent(kSbEventTypePreload)); -#else // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#else // SB_API_VERSION >= 6 SB_NOTREACHED(); -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 } bool Application::HasPreloadSwitch() { @@ -207,13 +207,13 @@ // Ensure that we go through the the appropriate lifecycle events based on the // current state. switch (scoped_event->event->type) { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypePreload: if (state() != kStateUnstarted) { return true; } break; -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 case kSbEventTypeStart: if (state() != kStatePreloading && state() != kStateUnstarted) { return true; @@ -294,12 +294,12 @@ SbEventHandle(scoped_event->event); switch (scoped_event->event->type) { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 case kSbEventTypePreload: SB_DCHECK(state() == kStateUnstarted); state_ = kStatePreloading; break; -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 case kSbEventTypeStart: SB_DCHECK(state() == kStatePreloading || state() == kStateUnstarted); state_ = kStateStarted; @@ -342,11 +342,11 @@ } Application::Event* Application::CreateInitialEvent(SbEventType type) { -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 SB_DCHECK(type == kSbEventTypePreload || type == kSbEventTypeStart); -#else // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#else // SB_API_VERSION >= 6 SB_DCHECK(type == kSbEventTypeStart); -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 SbEventStartData* start_data = new SbEventStartData(); SbMemorySet(start_data, 0, sizeof(SbEventStartData)); start_data->argument_values =
diff --git a/src/starboard/shared/starboard/file_storage/storage_delete_record.cc b/src/starboard/shared/starboard/file_storage/storage_delete_record.cc index c5c7fe3..cdfecce 100644 --- a/src/starboard/shared/starboard/file_storage/storage_delete_record.cc +++ b/src/starboard/shared/starboard/file_storage/storage_delete_record.cc
@@ -19,18 +19,18 @@ #include "starboard/user.h" bool SbStorageDeleteRecord(SbUser user -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 , const char* name -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 ) { if (!SbUserIsValid(user)) { return false; } -#if SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION < 6 const char* name = NULL; -#endif // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION < 6 char path[SB_FILE_MAX_PATH]; bool success = starboard::shared::starboard::GetUserStorageFilePath(
diff --git a/src/starboard/shared/starboard/file_storage/storage_internal.h b/src/starboard/shared/starboard/file_storage/storage_internal.h index a56cd34..4bbc117 100644 --- a/src/starboard/shared/starboard/file_storage/storage_internal.h +++ b/src/starboard/shared/starboard/file_storage/storage_internal.h
@@ -29,9 +29,9 @@ struct SbStorageRecordPrivate { SbUser user; SbFile file; -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 std::string name; -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 }; namespace starboard {
diff --git a/src/starboard/shared/starboard/file_storage/storage_open_record.cc b/src/starboard/shared/starboard/file_storage/storage_open_record.cc index aaea393..8417083 100644 --- a/src/starboard/shared/starboard/file_storage/storage_open_record.cc +++ b/src/starboard/shared/starboard/file_storage/storage_open_record.cc
@@ -20,18 +20,18 @@ #include "starboard/user.h" SbStorageRecord SbStorageOpenRecord(SbUser user -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 , const char* name -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 ) { if (!SbUserIsValid(user)) { return kSbStorageInvalidRecord; } -#if SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION < 6 const char* name = NULL; -#endif // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION < 6 char path[SB_FILE_MAX_PATH]; bool success = starboard::shared::starboard::GetUserStorageFilePath( @@ -52,7 +52,7 @@ SB_DCHECK(SbStorageIsValidRecord(result)); result->user = user; result->file = file; -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 if (name) { result->name = name; }
diff --git a/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc b/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc index 276c6c5..a04991b 100644 --- a/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc +++ b/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc
@@ -60,7 +60,7 @@ volume_(1.0), output_mode_(output_mode), decode_target_graphics_context_provider_(provider) { -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 if (audio_header_.audio_specific_config_size > 0) { audio_specific_config_.reset( new int8_t[audio_header_.audio_specific_config_size]); @@ -69,7 +69,7 @@ audio_header.audio_specific_config, audio_header.audio_specific_config_size); } -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 update_closure_ = Bind(&FilterBasedPlayerWorkerHandler::Update, this); bounds_ = PlayerWorker::Bounds();
diff --git a/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h b/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h index efceeaa..3e441fa 100644 --- a/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h +++ b/src/starboard/shared/starboard/player/filter/filter_based_player_worker_handler.h
@@ -76,11 +76,11 @@ SbMediaVideoCodec video_codec_; SbMediaAudioCodec audio_codec_; SbDrmSystem drm_system_; -#if SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#if SB_API_VERSION >= 6 // Store a copy of |SbMediaAudioHeader::audio_specific_config| passed to the // ctor so it is valid for the life time of the player worker. scoped_array<int8_t> audio_specific_config_; -#endif // SB_API_VERSION >= SB_AUDIO_SPECIFIC_CONFIG_AS_POINTER +#endif // SB_API_VERSION >= 6 SbMediaAudioHeader audio_header_; scoped_ptr<AudioRenderer> audio_renderer_;
diff --git a/src/starboard/shared/starboard/player/player_write_sample.cc b/src/starboard/shared/starboard/player/player_write_sample.cc index 770b981..62122dc 100644 --- a/src/starboard/shared/starboard/player/player_write_sample.cc +++ b/src/starboard/shared/starboard/player/player_write_sample.cc
@@ -19,13 +19,13 @@ void SbPlayerWriteSample(SbPlayer player, SbMediaType sample_type, -#if SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#if SB_API_VERSION >= 6 const void* const* sample_buffers, const int* sample_buffer_sizes, -#else // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#else // SB_API_VERSION >= 6 const void** sample_buffers, int* sample_buffer_sizes, -#endif // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#endif // SB_API_VERSION >= 6 int number_of_sample_buffers, SbMediaTime sample_pts, const SbMediaVideoSampleInfo* video_sample_info,
diff --git a/src/starboard/shared/stub/drm_create_system.cc b/src/starboard/shared/stub/drm_create_system.cc index 64139a9..5b43825 100644 --- a/src/starboard/shared/stub/drm_create_system.cc +++ b/src/starboard/shared/stub/drm_create_system.cc
@@ -14,7 +14,7 @@ #include "starboard/drm.h" -#if SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#if SB_API_VERSION >= 6 SbDrmSystem SbDrmCreateSystem( const char* key_system, @@ -30,7 +30,7 @@ return kSbDrmSystemInvalid; } -#else // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#else // SB_API_VERSION >= 6 SbDrmSystem SbDrmCreateSystem( const char* key_system, @@ -44,4 +44,4 @@ return kSbDrmSystemInvalid; } -#endif // SB_API_VERSION >= SB_DRM_KEY_STATUSES_UPDATE_SUPPORT_API_VERSION +#endif // SB_API_VERSION >= 6
diff --git a/src/starboard/shared/stub/player_write_sample.cc b/src/starboard/shared/stub/player_write_sample.cc index e08b4b4..b5a02eb 100644 --- a/src/starboard/shared/stub/player_write_sample.cc +++ b/src/starboard/shared/stub/player_write_sample.cc
@@ -20,13 +20,13 @@ void SbPlayerWriteSample(SbPlayer /*player*/, SbMediaType /*sample_type*/, -#if SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#if SB_API_VERSION >= 6 const void* const* /*sample_buffers*/, const int* /*sample_buffer_sizes*/, -#else // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#else // SB_API_VERSION >= 6 const void** /*sample_buffers*/, int* /*sample_buffer_sizes*/, -#endif // SB_API_VERSION >= SB_PLAYER_WRITE_SAMPLE_EXTRA_CONST_API_VERSION +#endif // SB_API_VERSION >= 6 int /*number_of_sample_buffers*/, SbMediaTime /*sample_pts*/, const SbMediaVideoSampleInfo* /*video_sample_info*/,
diff --git a/src/starboard/shared/stub/storage_delete_record.cc b/src/starboard/shared/stub/storage_delete_record.cc index a669054..6a1c2e0 100644 --- a/src/starboard/shared/stub/storage_delete_record.cc +++ b/src/starboard/shared/stub/storage_delete_record.cc
@@ -15,10 +15,10 @@ #include "starboard/storage.h" bool SbStorageDeleteRecord(SbUser /*user*/ -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 , const char* /*name*/ -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 ) { return false; }
diff --git a/src/starboard/shared/stub/storage_open_record.cc b/src/starboard/shared/stub/storage_open_record.cc index b0f503e..378e9e7 100644 --- a/src/starboard/shared/stub/storage_open_record.cc +++ b/src/starboard/shared/stub/storage_open_record.cc
@@ -15,10 +15,10 @@ #include "starboard/storage.h" SbStorageRecord SbStorageOpenRecord(SbUser /*user*/ -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 , const char* /*name*/ -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 ) { return kSbStorageInvalidRecord; }
diff --git a/src/starboard/shared/stub/system_raise_platform_error.cc b/src/starboard/shared/stub/system_raise_platform_error.cc index aad4c25..8380e52 100644 --- a/src/starboard/shared/stub/system_raise_platform_error.cc +++ b/src/starboard/shared/stub/system_raise_platform_error.cc
@@ -27,7 +27,7 @@ case kSbSystemPlatformErrorTypeConnectionError: message = "Connection error."; break; -#if SB_API_VERSION < SB_PLATFORM_ERROR_CLEANUP_API_VERSION +#if SB_API_VERSION < 6 case kSbSystemPlatformErrorTypeUserSignedOut: message = "User is not signed in."; break;
diff --git a/src/starboard/shared/stub/time_zone_get_dst_name.cc b/src/starboard/shared/stub/time_zone_get_dst_name.cc index 9d96599..35dad67 100644 --- a/src/starboard/shared/stub/time_zone_get_dst_name.cc +++ b/src/starboard/shared/stub/time_zone_get_dst_name.cc
@@ -14,8 +14,8 @@ #include "starboard/time_zone.h" -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 const char* SbTimeZoneGetDstName() { return "GMT"; } -#endif // SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#endif // SB_API_VERSION < 6
diff --git a/src/starboard/shared/uwp/application_uwp.cc b/src/starboard/shared/uwp/application_uwp.cc index ec9f438..2343b2a 100644 --- a/src/starboard/shared/uwp/application_uwp.cc +++ b/src/starboard/shared/uwp/application_uwp.cc
@@ -84,8 +84,8 @@ namespace { -const HdcpProtection kHDCPProtectionMode = - HdcpProtection::OnWithTypeEnforcement; +// Per Microsoft, HdcpProtection::On means HDCP 1.x required. +const HdcpProtection kHDCPProtectionMode = HdcpProtection::On; const int kWinSockVersionMajor = 2; const int kWinSockVersionMinor = 2;
diff --git a/src/starboard/shared/x11/application_x11.cc b/src/starboard/shared/x11/application_x11.cc index 387cb37..d9d156b 100644 --- a/src/starboard/shared/x11/application_x11.cc +++ b/src/starboard/shared/x11/application_x11.cc
@@ -609,7 +609,7 @@ if (state & ShiftMask) { key_modifiers |= kSbKeyModifiersShift; } -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 if (state & Button1Mask) { key_modifiers |= kSbKeyModifiersPointerButtonLeft; } @@ -629,7 +629,7 @@ return key_modifiers; } -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 SbInputVector XButtonEventToSbInputVectorDelta(XButtonEvent* event) { SbInputVector delta = {0, 0}; switch (event->button) { @@ -1175,7 +1175,7 @@ XButtonEvent* x_button_event = reinterpret_cast<XButtonEvent*>(x_event); bool is_press_event = ButtonPress == x_event->type; bool is_wheel_event = XButtonEventIsWheelEvent(x_button_event); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 if (is_wheel_event && !is_press_event) { // unpress events from the wheel are discarded. return NULL; @@ -1190,7 +1190,7 @@ is_press_event ? kSbInputEventTypePress : kSbInputEventTypeUnpress; data->device_type = kSbInputDeviceTypeMouse; if (is_wheel_event) { -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 data->pressure = NAN; data->size = {NAN, NAN}; data->tilt = {NAN, NAN}; @@ -1215,7 +1215,7 @@ SbMemorySet(data.get(), 0, sizeof(*data)); data->window = FindWindow(x_motion_event->window); SB_DCHECK(SbWindowIsValid(data->window)); -#if SB_API_VERSION >= SB_POINTER_INPUT_API_VERSION +#if SB_API_VERSION >= 6 data->pressure = NAN; data->size = {NAN, NAN}; data->tilt = {NAN, NAN};
diff --git a/src/starboard/shared/x11/application_x11.h b/src/starboard/shared/x11/application_x11.h index 48d32d7..ee9fe6a 100644 --- a/src/starboard/shared/x11/application_x11.h +++ b/src/starboard/shared/x11/application_x11.h
@@ -59,10 +59,10 @@ int width, int height) SB_OVERRIDE; -#if SB_API_VERSION >= SB_PRELOAD_API_VERSION +#if SB_API_VERSION >= 6 bool IsStartImmediate() SB_OVERRIDE { return !HasPreloadSwitch(); } bool IsPreloadImmediate() SB_OVERRIDE { return HasPreloadSwitch(); } -#endif // SB_API_VERSION >= SB_PRELOAD_API_VERSION +#endif // SB_API_VERSION >= 6 protected: // --- Application overrides ---
diff --git a/src/starboard/storage.h b/src/starboard/storage.h index 33ba547..c3d9963 100644 --- a/src/starboard/storage.h +++ b/src/starboard/storage.h
@@ -51,7 +51,7 @@ return record != kSbStorageInvalidRecord; } -#if SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION < 6 // Opens and returns the default SbStorageRecord for |user|, blocking I/O on the // calling thread until the open is completed. If |user| is not a valid @@ -62,7 +62,7 @@ // |user|: The user for which the storage record will be opened. SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user); -#else // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION < 6 // Opens and returns the SbStorageRecord for |user| named |name|, blocking I/O // on the calling thread until the open is completed. If |user| is not a valid @@ -77,7 +77,7 @@ // |name|: The filesystem-safe name of the record to open. SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name); -#endif // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION < 6 // Closes |record|, synchronously ensuring that all written data is flushed. // This function performs blocking I/O on the calling thread. @@ -131,7 +131,7 @@ const char* data, int64_t data_size); -#if SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION < 6 // Deletes the default |SbStorageRecord| for the |user|. The return value // indicates whether the record existed and was successfully deleted. If the @@ -143,7 +143,7 @@ // |user|: The user for whom the record will be deleted. SB_EXPORT bool SbStorageDeleteRecord(SbUser user); -#else // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION < 6 // Deletes the |SbStorageRecord| for |user| named |name|. The return value // indicates whether the record existed and was successfully deleted. If the @@ -159,7 +159,7 @@ // |name|: The filesystem-safe name of the record to open. SB_EXPORT bool SbStorageDeleteRecord(SbUser user, const char* name); -#endif // SB_API_VERSION < SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION < 6 #ifdef __cplusplus } // extern "C" @@ -183,7 +183,7 @@ Initialize(); } -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 explicit StorageRecord(const char* name) : user_(SbUserGetCurrent()), name_(name), @@ -195,7 +195,7 @@ : user_(user), name_(name), record_(kSbStorageInvalidRecord) { Initialize(); } -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 ~StorageRecord() { Close(); } bool IsValid() { return SbStorageIsValidRecord(record_); } @@ -219,36 +219,36 @@ bool Delete() { Close(); -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 if (!name_.empty()) { return SbStorageDeleteRecord(user_, name_.c_str()); } else { return SbStorageDeleteRecord(user_, NULL); } -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 return SbStorageDeleteRecord(user_); -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 } private: void Initialize() { if (SbUserIsValid(user_)) { -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 if (!name_.empty()) { record_ = SbStorageOpenRecord(user_, name_.c_str()); } else { record_ = SbStorageOpenRecord(user_, NULL); } -#else // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#else // SB_API_VERSION >= 6 record_ = SbStorageOpenRecord(user_); -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 } } SbUser user_; -#if SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#if SB_API_VERSION >= 6 std::string name_; -#endif // SB_API_VERSION >= SB_STORAGE_NAMES_API_VERSION +#endif // SB_API_VERSION >= 6 SbStorageRecord record_; };
diff --git a/src/starboard/system.h b/src/starboard/system.h index cfa9eed..3a4444e 100644 --- a/src/starboard/system.h +++ b/src/starboard/system.h
@@ -185,7 +185,7 @@ // retried, otherwise the app should be stopped. kSbSystemPlatformErrorTypeConnectionError, -#if SB_API_VERSION < SB_PLATFORM_ERROR_CLEANUP_API_VERSION +#if SB_API_VERSION < 6 // The current user is not signed in. kSbSystemPlatformErrorTypeUserSignedOut,
diff --git a/src/starboard/time_zone.h b/src/starboard/time_zone.h index e3bf9c6..b4aec2e 100644 --- a/src/starboard/time_zone.h +++ b/src/starboard/time_zone.h
@@ -35,7 +35,7 @@ // Gets the system's current SbTimeZone in minutes. SB_EXPORT SbTimeZone SbTimeZoneGetCurrent(); -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 // Gets the three-letter code of the current timezone in standard time, // regardless of current Daylight Savings Time status. (e.g. "PST") #else @@ -48,11 +48,11 @@ #endif SB_EXPORT const char* SbTimeZoneGetName(); -#if SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#if SB_API_VERSION < 6 // Gets the three-letter code of the current timezone in Daylight Savings Time, // regardless of current DST status. (e.g. "PDT") SB_EXPORT const char* SbTimeZoneGetDstName(); -#endif // SB_API_VERSION < SB_TIME_ZONE_FLEXIBLE_API_VERSION +#endif // SB_API_VERSION < 6 #ifdef __cplusplus } // extern "C"