Switch to a smoother stretch algorithm on Windows and delete buffers from previous conversations on linux when switching back to peer list.

Review URL: http://webrtc-codereview.appspot.com/135003

git-svn-id: http://webrtc.googlecode.com/svn/trunk@488 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tommi@webrtc.org 2011-08-30 08:39:04 +00:00
parent 3266d8d85d
commit 8811e5af02
2 changed files with 29 additions and 7 deletions

View File

@ -141,14 +141,12 @@ MainWindow::UI GtkMainWnd::current_ui() {
}
cricket::VideoRenderer* GtkMainWnd::local_renderer() {
if (!local_renderer_.get())
local_renderer_.reset(new VideoRenderer(this));
ASSERT(local_renderer_.get() != NULL);
return local_renderer_.get();
}
cricket::VideoRenderer* GtkMainWnd::remote_renderer() {
if (!remote_renderer_.get())
remote_renderer_.reset(new VideoRenderer(this));
ASSERT(remote_renderer_.get() != NULL);
return remote_renderer_.get();
}
@ -234,6 +232,10 @@ void GtkMainWnd::SwitchToConnectUI() {
void GtkMainWnd::SwitchToPeerList(const Peers& peers) {
LOG(INFO) << __FUNCTION__;
// Clean up buffers from a potential previous session.
local_renderer_.reset();
remote_renderer_.reset();
if (!peer_list_) {
gtk_container_set_border_width(GTK_CONTAINER(window_), 0);
if (vbox_) {
@ -270,6 +272,12 @@ void GtkMainWnd::SwitchToStreamingUI() {
ASSERT(draw_area_ == NULL);
// Prepare new buffers for the new conversation. We don't
// reuse buffers across sessions to avoid possibly rendering
// a frame from the previous conversation.
remote_renderer_.reset(new VideoRenderer(this));
local_renderer_.reset(new VideoRenderer(this));
gtk_container_set_border_width(GTK_CONTAINER(window_), 0);
if (peer_list_) {
gtk_widget_destroy(peer_list_);

View File

@ -22,6 +22,11 @@ const wchar_t MainWnd::kClassName[] = L"WebRTC_MainWnd";
std::string GetDefaultServerName();
namespace {
const char kConnecting[] = "Connecting... ";
const char kNoVideoStreams[] = "(no video streams either way)";
const char kNoIncomingStream[] = "(no incoming video)";
void CalculateWindowSizeForText(HWND wnd, const wchar_t* text,
size_t* width, size_t* height) {
HDC dc = ::GetDC(wnd);
@ -192,8 +197,10 @@ void MainWnd::OnPaint() {
long height = abs(bmi.bmiHeader.biHeight);
long width = bmi.bmiHeader.biWidth;
if (remote_video_.get()->image() != NULL) {
const uint8* image = remote_video_->image();
if (image != NULL) {
HDC dc_mem = ::CreateCompatibleDC(ps.hdc);
::SetStretchBltMode(dc_mem, HALFTONE);
// Set the map mode so that the ratio will be maintained for us.
HDC all_dc[] = { ps.hdc, dc_mem };
@ -214,7 +221,6 @@ void MainWnd::OnPaint() {
::FillRect(dc_mem, &logical_rect, brush);
::DeleteObject(brush);
const uint8* image = remote_video_->image();
int max_unit = std::max(width, height);
int x = (logical_area.x / 2) - (width / 2);
int y = (logical_area.y / 2) - (height / 2);
@ -247,10 +253,18 @@ void MainWnd::OnPaint() {
HBRUSH brush = ::CreateSolidBrush(RGB(0, 0, 0));
::FillRect(ps.hdc, &rc, brush);
::DeleteObject(brush);
HGDIOBJ old_font = ::SelectObject(ps.hdc, GetDefaultFont());
::SetTextColor(ps.hdc, RGB(0xff, 0xff, 0xff));
::SetBkMode(ps.hdc, TRANSPARENT);
::DrawTextA(ps.hdc, "Connecting...", -1, &rc,
std::string text(kConnecting);
if (!local_video_->image()) {
text += kNoVideoStreams;
} else {
text += kNoIncomingStream;
}
::DrawTextA(ps.hdc, text.c_str(), -1, &rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
::SelectObject(ps.hdc, old_font);
}