Skip to content

Commit

Permalink
Merge branch 'main' into fix-pthread
Browse files Browse the repository at this point in the history
  • Loading branch information
haozheng-cobalt authored Aug 15, 2024
2 parents 72b8437 + 2a9a01c commit edb14ab
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 45 deletions.
50 changes: 32 additions & 18 deletions cobalt/browser/browser_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ BrowserModule::BrowserModule(const GURL& url,
splash_screen_layer_ = render_tree_combiner_.CreateLayer(kSplashScreenZIndex);
// Create the debug console layer.
#if defined(ENABLE_DEBUGGER)
debug_console_layer_ = render_tree_combiner_.CreateLayer(kDebugConsoleZIndex);
if (DebugConsole::IsEnabled()) {
debug_console_layer_ =
render_tree_combiner_.CreateLayer(kDebugConsoleZIndex);
}
#endif

int qr_code_overlay_slots = 4;
Expand Down Expand Up @@ -367,15 +370,17 @@ BrowserModule::BrowserModule(const GURL& url,
resource_provider_stub_.emplace(true /*allocate_image_data*/);

#if defined(ENABLE_DEBUGGER)
debug_console_.reset(new DebugConsole(
platform_info_.get(), application_state_,
base::Bind(&BrowserModule::QueueOnDebugConsoleRenderTreeProduced,
base::Unretained(this)),
&web_settings_, network_module_, GetViewportSize(), GetResourceProvider(),
kLayoutMaxRefreshFrequencyInHz,
base::Bind(&BrowserModule::CreateDebugClient, base::Unretained(this)),
base::Bind(&BrowserModule::OnMaybeFreeze, base::Unretained(this))));
lifecycle_observers_.AddObserver(debug_console_.get());
if (debug_console_layer_) {
debug_console_.reset(new DebugConsole(
platform_info_.get(), application_state_,
base::Bind(&BrowserModule::QueueOnDebugConsoleRenderTreeProduced,
base::Unretained(this)),
&web_settings_, network_module_, GetViewportSize(),
GetResourceProvider(), kLayoutMaxRefreshFrequencyInHz,
base::Bind(&BrowserModule::CreateDebugClient, base::Unretained(this)),
base::Bind(&BrowserModule::OnMaybeFreeze, base::Unretained(this))));
lifecycle_observers_.AddObserver(debug_console_.get());
}
#endif // defined(ENABLE_DEBUGGER)

const renderer::Pipeline* pipeline =
Expand Down Expand Up @@ -1095,6 +1100,7 @@ void BrowserModule::OnDisableMediaCodecs(const std::string& codecs) {

void BrowserModule::QueueOnDebugConsoleRenderTreeProduced(
const browser::WebModule::LayoutResults& layout_results) {
#if defined(ENABLE_DEBUGGER)
TRACE_EVENT0("cobalt::browser",
"BrowserModule::QueueOnDebugConsoleRenderTreeProduced()");
render_tree_submission_queue_.AddMessage(
Expand All @@ -1103,14 +1109,17 @@ void BrowserModule::QueueOnDebugConsoleRenderTreeProduced(
task_runner_->PostTask(
FROM_HERE,
base::Bind(&BrowserModule::ProcessRenderTreeSubmissionQueue, weak_this_));
#endif
}

void BrowserModule::OnDebugConsoleRenderTreeProduced(
const browser::WebModule::LayoutResults& layout_results) {
#if defined(ENABLE_DEBUGGER)
TRACE_EVENT0("cobalt::browser",
"BrowserModule::OnDebugConsoleRenderTreeProduced()");
DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (application_state_ == base::kApplicationStateConcealed) {
if (!debug_console_ ||
(application_state_ == base::kApplicationStateConcealed)) {
return;
}

Expand All @@ -1127,6 +1136,7 @@ void BrowserModule::OnDebugConsoleRenderTreeProduced(
}

SubmitCurrentRenderTreeToRenderer();
#endif
}

void BrowserModule::OnNavigateTimedTrace(const std::string& time) {
Expand All @@ -1151,7 +1161,8 @@ void BrowserModule::OnOnScreenKeyboardInputEventProduced(
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterOnScreenKeyboardInputEvent(type, event)) {
if (debug_console_ &&
!debug_console_->FilterOnScreenKeyboardInputEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand Down Expand Up @@ -1188,7 +1199,7 @@ void BrowserModule::OnPointerEventProduced(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterPointerEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterPointerEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand All @@ -1214,7 +1225,7 @@ void BrowserModule::OnWheelEventProduced(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterWheelEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterWheelEvent(type, event)) {
return;
}
#endif // defined(ENABLE_DEBUGGER)
Expand Down Expand Up @@ -1348,7 +1359,7 @@ bool BrowserModule::FilterKeyEvent(base_token::Token type,
}

#if defined(ENABLE_DEBUGGER)
if (!debug_console_->FilterKeyEvent(type, event)) {
if (debug_console_ && !debug_console_->FilterKeyEvent(type, event)) {
return false;
}
#endif // defined(ENABLE_DEBUGGER)
Expand All @@ -1359,8 +1370,9 @@ bool BrowserModule::FilterKeyEvent(base_token::Token type,
bool BrowserModule::FilterKeyEventForHotkeys(
base_token::Token type, const dom::KeyboardEventInit& event) {
#if defined(ENABLE_DEBUGGER)
if (event.key_code() == dom::keycode::kF1 ||
(event.ctrl_key() && event.key_code() == dom::keycode::kO)) {
if (debug_console_ &&
(event.key_code() == dom::keycode::kF1 ||
(event.ctrl_key() && event.key_code() == dom::keycode::kO))) {
if (type == base::Tokens::keydown()) {
// F1 or Ctrl+O cycles the debug console display.
debug_console_->CycleMode();
Expand Down Expand Up @@ -1754,7 +1766,9 @@ void BrowserModule::ResetResources() {
main_web_module_layer_->Reset();
splash_screen_layer_->Reset();
#if defined(ENABLE_DEBUGGER)
debug_console_layer_->Reset();
if (debug_console_layer_) {
debug_console_layer_->Reset();
}
#endif // defined(ENABLE_DEBUGGER)
if (qr_overlay_info_layer_) {
qr_overlay_info_layer_->Reset();
Expand Down
12 changes: 12 additions & 0 deletions cobalt/browser/debug_console.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,18 @@ DebugConsole::DebugConsole(

DebugConsole::~DebugConsole() {}

// static
bool DebugConsole::IsEnabled() {
#if defined(ENABLE_DEBUGGER)
// The debug console is not enabled when it's turned off from the
// command-line.
return GetDebugConsoleModeFromCommandLine() !=
debug::console::kDebugConsoleModeOff;
#else
return false;
#endif
}

bool DebugConsole::ShouldInjectInputEvents() {
switch (GetMode()) {
case debug::console::kDebugConsoleModeOff:
Expand Down
3 changes: 3 additions & 0 deletions cobalt/browser/debug_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class DebugConsole : public LifecycleObserver {
// Cycles through each different possible debug console visibility mode.
void CycleMode();

// Returns true if the debug console is enabled.
static bool IsEnabled();

// Returns true iff the console is in a mode that is visible.
bool IsVisible() {
return (GetMode() != debug::console::kDebugConsoleModeOff);
Expand Down
10 changes: 6 additions & 4 deletions starboard/android/apk/apk_sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,37 @@
apk_sources = [
"//starboard/android/apk/app/src/app/java/dev/cobalt/app/CobaltApplication.java",
"//starboard/android/apk/app/src/app/java/dev/cobalt/app/MainActivity.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloader.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkDownloaderDefault.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ArtworkLoader.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/AudioPermissionRequester.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CaptionSettings.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltA11yHelper.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltActivity.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltHttpHelper.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltMediaSession.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltService.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltSystemConfigChangeReceiver.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CobaltTextToSpeechHelper.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/CrashContextUpdateHandler.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ErrorDialog.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/MediaImage.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/NetworkStatus.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/NullCobaltFactory.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/PlatformError.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/ResourceOverlay.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/libraries/services/clientloginfo/ClientLogInfo.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/libraries/services/clientloginfo/ClientLogInfoModule.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/ArtworkLoader.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioOutputManager.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/AudioTrackBridge.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/CaptionSettings.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/CobaltMediaSession.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/Log.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridge.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecBridgeBuilder.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecCapabilitiesLogger.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaCodecUtil.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaDrmBridge.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaFormatBuilder.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/MediaImage.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoFrameReleaseTimeHelper.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoSurfaceTexture.java",
"//starboard/android/apk/app/src/main/java/dev/cobalt/media/VideoSurfaceView.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

import android.app.Activity;
import android.app.Service;
import dev.cobalt.coat.ArtworkDownloaderDefault;
import dev.cobalt.coat.CobaltActivity;
import dev.cobalt.coat.CobaltService;
import dev.cobalt.coat.StarboardBridge;
import dev.cobalt.libraries.services.clientloginfo.ClientLogInfoModule;
import dev.cobalt.media.ArtworkDownloaderDefault;
import dev.cobalt.util.Holder;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

/**
* Interface to download artwork (Bitmap) from a URL, intended for use in media session metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

import static dev.cobalt.media.Log.TAG;
import static dev.cobalt.util.Log.TAG;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

import android.graphics.Bitmap;
import android.os.Handler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

import android.view.accessibility.CaptioningManager;
import dev.cobalt.util.UsedByNative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

import static dev.cobalt.media.Log.TAG;
import static dev.cobalt.util.Log.TAG;

import android.app.Activity;
import android.content.Context;
Expand Down Expand Up @@ -50,7 +50,7 @@ public class CobaltMediaSession

private AudioFocusRequest audioFocusRequest;

interface UpdateVolumeListener {
public interface UpdateVolumeListener {
/** Called when there is a change in audio focus. */
void onUpdateVolume(float gain);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package dev.cobalt.media;
package dev.cobalt.coat;

import dev.cobalt.util.UsedByNative;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.CaptioningManager;
import androidx.annotation.Nullable;
import dev.cobalt.media.ArtworkDownloader;
import dev.cobalt.media.AudioOutputManager;
import dev.cobalt.media.CaptionSettings;
import dev.cobalt.media.CobaltMediaSession;
import dev.cobalt.media.MediaImage;
import dev.cobalt.util.DisplayUtil;
import dev.cobalt.util.Holder;
import dev.cobalt.util.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import android.media.AudioTrack;
import android.os.Build;
import androidx.annotation.RequiresApi;
import dev.cobalt.coat.CobaltMediaSession;
import dev.cobalt.util.Log;
import dev.cobalt.util.UsedByNative;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ bool GetCaptionSettings(SbAccessibilityCaptionSettings* caption_settings) {

ScopedLocalJavaRef<jobject> j_caption_settings(
env->CallStarboardObjectMethodOrAbort(
"getCaptionSettings", "()Ldev/cobalt/media/CaptionSettings;"));
"getCaptionSettings", "()Ldev/cobalt/coat/CaptionSettings;"));

jfloat font_scale =
env->GetFloatFieldOrAbort(j_caption_settings.Get(), "fontScale", "F");
Expand Down
12 changes: 6 additions & 6 deletions starboard/android/shared/android_media_session_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void OnMediaSessionStateChanged(
if (artwork_count > 0) {
CobaltExtensionMediaImage* artwork(media_metadata->artwork);
ScopedLocalJavaRef<jclass> media_image_class(
env->FindClassExtOrAbort("dev/cobalt/media/MediaImage"));
env->FindClassExtOrAbort("dev/cobalt/coat/MediaImage"));
jmethodID media_image_constructor = env->GetMethodID(
media_image_class.Get(), "<init>",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
Expand Down Expand Up @@ -234,7 +234,7 @@ void OnMediaSessionStateChanged(
env->CallStarboardVoidMethodOrAbort(
"updateMediaSession",
"(IJJFLjava/lang/String;Ljava/lang/String;Ljava/lang/String;"
"[Ldev/cobalt/media/MediaImage;J)V",
"[Ldev/cobalt/coat/MediaImage;J)V",
playback_state, playback_state_actions,
session_state.current_playback_position / 1000,
static_cast<jfloat>(session_state.actual_playback_rate), j_title.Get(),
Expand Down Expand Up @@ -290,9 +290,9 @@ const void* GetMediaSessionApi() {
} // namespace starboard

extern "C" SB_EXPORT_PLATFORM void
Java_dev_cobalt_media_CobaltMediaSession_nativeInvokeAction(JNIEnv* env,
jclass unused_clazz,
jlong action,
jlong seek_ms) {
Java_dev_cobalt_coat_CobaltMediaSession_nativeInvokeAction(JNIEnv* env,
jclass unused_clazz,
jlong action,
jlong seek_ms) {
starboard::android::shared::NativeInvokeAction(action, seek_ms);
}
4 changes: 2 additions & 2 deletions starboard/shared/win32/file_open.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if SB_API_VERSION < 16
#if SB_API_VERSION < 17

#include "starboard/file.h"

Expand Down Expand Up @@ -42,4 +42,4 @@ SbFile SbFileOpen(const char* path,
return new SbFilePrivate(file_handle);
}

#endif // SB_API_VERSION < 16
#endif // SB_API_VERSION < 17

0 comments on commit edb14ab

Please sign in to comment.