bool AbortTask::UpdateSample(const AircraftState &state, const GlidePolar &glide_polar, bool full_update) { Clear(); unsigned active_waypoint_on_entry; if (is_active) active_waypoint_on_entry = active_waypoint; else { active_waypoint = 0; active_waypoint_on_entry = (unsigned) -1 ; } active_task_point = 0; // default to best result if can't find user-set one AlternateVector approx_waypoints; approx_waypoints.reserve(128); WaypointVisitorVector wvv(approx_waypoints); waypoints.VisitWithinRange(state.location, GetAbortRange(state, glide_polar), wvv); if (approx_waypoints.empty()) { /** @todo increase range */ return false; } // sort by arrival time // first try with final glide only reachable_landable |= FillReachable(state, approx_waypoints, glide_polar, true, true, true); reachable_landable |= FillReachable(state, approx_waypoints, glide_polar, false, true, true); // inform clients that the landable reachable scan has been performed ClientUpdate(state, true); // now try without final glide constraint and not preferring airports FillReachable(state, approx_waypoints, glide_polar, false, false, false); // inform clients that the landable unreachable scan has been performed ClientUpdate(state, false); if (task_points.size()) { const TaskWaypoint &task_point = task_points[active_task_point]; active_waypoint = task_point.GetWaypoint().id; if (is_active && (active_waypoint_on_entry != active_waypoint)) { if (task_events != NULL) task_events->ActiveChanged(task_point); return true; } } return false; // nothing to do }
void MediaPlayerPrivateEA::UpdateTimerFired(Timer<MediaPlayerPrivateEA>*) { // We can use this to control the movie playback and make sure the media player is getting all the info it needs. // Currently we just feed it repaint and a pause. This seems to work good enough for basic playback control but // we might have to revise this if further synchronization is needed between a movie player and the internal media player system. ClientUpdateStates(); // Get the natural size here so that we control when it changes (so it does not occur in the paint). ClientUpdate(MediaUpdateInfo::kGetNaturalSize); if (mNaturalSize != GetMediaUpdateInfo().mReturnNaturalSize) { mNaturalSize = GetMediaUpdateInfo().mReturnNaturalSize; mpWebCorePlayer->sizeChanged(); } if (mMediaState == MediaUpdateInfo::kFinished) { mIsFinished = true; if(mIsPlaying) { mIsPlaying = false; // This will trigger a play request when calling the play button. // Pause if done playing so that the play arrow button shows up for possible replay. HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient()); element->pause(); } } // The movie paint needs to be ticked so that the controls get repainted and the view updated. mpWebCorePlayer->repaint(); }
MediaPlayerPrivateEA::~MediaPlayerPrivateEA() { ClientUpdate(MediaUpdateInfo::kDestroy); mUpdateTimer.stop(); sRefCount--; if (!sRefCount) Finalize(); }
void MediaPlayerPrivateEA::setVisible(bool visible) { // Filter out identical calls. if(mIsVisible == visible) return; if(!mpEAWebKitView) mpEAWebKitView = GetEAWebKitMediaView(mpWebCorePlayer); mIsVisible = visible; GetMediaUpdateInfo().mIsVisible = visible; ClientUpdate(MediaUpdateInfo::kVisible); }
void MediaPlayerPrivateEA::play() { if(!mIsPlaying) { mMediaState = MediaUpdateInfo::kPlaying; mIsFinished = false; mIsPlaying = true; mMovieRect.setWidth(0); // Invalidate. This is used to detect window size changes. mWindowRect.setWidth(0); } GetMediaUpdateInfo().mIsLooping = mIsLooping; ClientUpdate(MediaUpdateInfo::kPlay); }
void MediaPlayerPrivateEA::load(const String& url) { if (!mpEAWebKitView) mpEAWebKitView = GetEAWebKitMediaView(mpWebCorePlayer); // Note: We get the autoplay and loop flags from the element directly. HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient()); mIsLooping = element->loop(); MediaUpdateInfo& info = GetMediaUpdateInfo(); info.mIsLooping = mIsLooping; WebCore::KURL kurl(WebCore::KURL(), url); String escapedUrl = kurl.protocolIsInHTTPFamily() ? url : decodeURLEscapeSequences(url); GetFixedString(info.mURI)->assign(escapedUrl.characters(), escapedUrl.length()); ClientUpdate(MediaUpdateInfo::kLoad); // Set info up to play setMuted(mpWebCorePlayer->muted()); setVolume(mpWebCorePlayer->volume()); if(mNetworkState != MediaPlayer::Loading) { mNetworkState = MediaPlayer::Loading; mpWebCorePlayer->networkStateChanged(); } if(mReadyState != MediaPlayer::HaveNothing) { mReadyState = MediaPlayer::HaveNothing; mpWebCorePlayer->readyStateChanged(); } bool autoPlay = element->autoplay(); if(autoPlay) mpWebCorePlayer->play(); // This just calls our play. ClientUpdateStates(); // This will update the pause/play state right away. // Set up an update timer to control the repaint and playback. if (mUpdateTimer.isActive()) mUpdateTimer.stop(); const double kUpdateTime = 1.0/60.0; // We want to update at 60hz so we keep up with the render calls. mUpdateTimer.startRepeating(kUpdateTime); }
void MediaPlayerPrivateEA::setRate(float rate) { GetMediaUpdateInfo().mRate = rate; ClientUpdate(MediaUpdateInfo::kRate); }
bool AbortTask::UpdateSample(const AircraftState &state, bool full_update) { UpdatePolar(state.wind); Clear(); const unsigned active_waypoint_on_entry = is_active ? active_waypoint : (unsigned)-1; active_task_point = 0; // default to best result if can't find user-set one AlternateVector approx_waypoints; approx_waypoints.reserve(128); WaypointVisitorVector wvv(approx_waypoints); waypoints.VisitWithinRange(state.location, GetAbortRange(state), wvv); if (approx_waypoints.empty()) { /** @todo increase range */ return false; } // lookup the appropriate polar to use const GlidePolar* mode_polar; switch (task_behaviour.route_planner.reach_polar_mode) { case RoutePlannerConfig::rpmTask: mode_polar = &glide_polar; // make copy to avoid waste break; case RoutePlannerConfig::rpmSafety: mode_polar = &polar_safety; break; default: assert(false); return false; } assert(mode_polar); // sort by alt difference // first try with final glide only reachable_landable |= FillReachable(state, approx_waypoints, *mode_polar, true, true, true); reachable_landable |= FillReachable(state, approx_waypoints, *mode_polar, false, true, true); // inform clients that the landable reachable scan has been performed ClientUpdate(state, true); // now try without final glide constraint and not preferring airports FillReachable(state, approx_waypoints, *mode_polar, false, false, false); // inform clients that the landable unreachable scan has been performed ClientUpdate(state, false); if (task_points.size()) { const TaskWaypoint &task_point = task_points[active_task_point]; active_waypoint = task_point.GetWaypoint().id; if (is_active && (active_waypoint_on_entry != active_waypoint)) { task_events.ActiveChanged(task_point); return true; } } return false; // nothing to do }
bool MediaPlayerPrivateEA::ClientUpdateAndReturnBool(MediaUpdateInfo::UpdateType type) const { ClientUpdate(type); return GetMediaUpdateInfo().mReturnBool; }
EA::WebKit::MediaUpdateInfo::MediaState MediaPlayerPrivateEA::ClientMediaState(void) const { ClientUpdate(MediaUpdateInfo::kGetMediaState); return GetMediaUpdateInfo().mReturnMediaState; }
void MediaPlayerPrivateEA::paint(GraphicsContext* context, const IntRect& r) { if (!context) return; // Can get a NULL platform context so need to verify. Seems that UpdateControlTints does what is called a "fake" paint // with a null platform context just to get an invalidate. PlatformContextCairo* pPlatformContext = context->platformContext(); if (!pPlatformContext) return; cairo_t* cr = context->platformContext()->cr(); if (!cr) return; MediaUpdateInfo& info = GetMediaUpdateInfo(); const FrameView* pFV = mpWebCorePlayer->frameView(); if (!pFV) return; // Convert and store movie rect to device coords using the graphic context. double x = (double) r.x(); double y = (double) r.y(); double w = (double) r.width(); double h = (double) r.height(); cairo_user_to_device (cr, &x, &y); cairo_user_to_device_distance(cr, &w, &h); const IntRect rect((int) x, (int) y, (int) w, (int) h); // The intersection of frameView contents and the movie is used as clip rect for we just want to know what part of the movie is visible. IntRect clip = pFV->windowClipRect(true); clip.intersect(rect); // Find controls intersection HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient()); if(element && element->controls()) { MediaControls* pControls = element->mediaControls(); bool hideControls = pControls->shouldHideControls(); if (!hideControls) { const int kControlHeight = 16; // EAWebKitTODO: Consider finding a way to extract this info directly from the controls or pass as a theme param. IntRect boundingRect = pControls->getRect(); x = (double) boundingRect.x(); y = (double) boundingRect.y(); w = (double) boundingRect.width(); h = (double) (boundingRect.height() - kControlHeight); cairo_user_to_device (cr, &x, &y); cairo_user_to_device_distance(cr, &w, &h); const IntRect ctrlRect((int) x, (int) y, (int) w, (int) h); clip.intersect(ctrlRect); } } if ((rect != mMovieRect) || (clip != mWindowRect)) { mMovieRect = rect; // Store copy locally to detect changes. mWindowRect = clip; info.mMovieRect = rect; info.mWindowRect = clip; ClientUpdate(MediaUpdateInfo::kWindowSize); } ClientUpdate(MediaUpdateInfo::kPaint); if (info.mReturnData) { // Draw surface to view #ifndef NDEBUG static bool sAssertChecked = false; if(!sAssertChecked) { EAW_ASSERT(!info.mReturnData); sAssertChecked = true; } #endif context->save(); RefPtr<cairo_surface_t> cairoSurface = adoptRef(cairo_image_surface_create_for_data((unsigned char*) info.mReturnData, CAIRO_FORMAT_ARGB32, w, h, w * sizeof(uint32_t))); EAW_ASSERT(cairo_surface_status(cairoSurface.get()) == CAIRO_STATUS_SUCCESS); cairo_set_source_surface(cr, cairoSurface.get(), rect.x(), rect.y()); cairo_paint(cr); context->restore(); } else { // Draw a default black background. context->save(); context->setStrokeStyle(NoStroke); context->setFillColor(Color::black, ColorSpaceDeviceRGB); context->drawRect(r); context->restore(); } }
unsigned MediaPlayerPrivateEA::bytesLoaded() const { ClientUpdate(MediaUpdateInfo::kGetBytesLoaded); return GetMediaUpdateInfo().mReturnBytes; }
void MediaPlayerPrivateEA::setMuted(bool mute) { GetMediaUpdateInfo().mIsMuted = mute; ClientUpdate(MediaUpdateInfo::kMute); }
void MediaPlayerPrivateEA::setVolume(float volume) { GetMediaUpdateInfo().mVolume = volume; ClientUpdate(MediaUpdateInfo::kVolume); }
float MediaPlayerPrivateEA::ClientUpdateAndReturnTime(MediaUpdateInfo::UpdateType type) const { ClientUpdate(type); return GetMediaUpdateInfo().mReturnTime; }
void MediaPlayerPrivateEA::seek(float time) { GetMediaUpdateInfo().mSeek = time; ClientUpdate(MediaUpdateInfo::kSeek); }
void MediaPlayerPrivateEA::pause() { ClientUpdate(MediaUpdateInfo::kPause); }
void MediaPlayerPrivateEA::cancelLoad() { ClientUpdate(MediaUpdateInfo::kCancelLoad); ClientUpdateStates(); }