summaryrefslogtreecommitdiffstats
path: root/remoting/client/plugin
diff options
context:
space:
mode:
authorgarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 17:51:57 +0000
committergarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 17:51:57 +0000
commite4f323a219824c30f130d2f34105bcda84c3a35f (patch)
tree81221a138ee85c805f07169d72fd637ad1f791cd /remoting/client/plugin
parent339b38a6e23e085e5d1faebb736c0414b5df694d (diff)
downloadchromium_src-e4f323a219824c30f130d2f34105bcda84c3a35f.zip
chromium_src-e4f323a219824c30f130d2f34105bcda84c3a35f.tar.gz
chromium_src-e4f323a219824c30f130d2f34105bcda84c3a35f.tar.bz2
Move common ChromotingView functionality into base class so that the code can
be shared between PepperView and X11View. Have View create appropriate decoder based on encoding of the update stream. Add state to decoder to keep track of whether Begin/End has been called in the correct order. Add unittests for new routines. BUG=none TEST=remoting unit tests Review URL: http://codereview.chromium.org/3124005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57206 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/plugin')
-rw-r--r--remoting/client/plugin/pepper_view.cc43
-rw-r--r--remoting/client/plugin/pepper_view.h11
2 files changed, 20 insertions, 34 deletions
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 6715888..86b70fc 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -5,7 +5,6 @@
#include "remoting/client/plugin/pepper_view.h"
#include "base/message_loop.h"
-#include "remoting/base/decoder_zlib.h"
#include "remoting/client/plugin/chromoting_instance.h"
#include "remoting/client/plugin/pepper_util.h"
#include "third_party/ppapi/cpp/device_context_2d.h"
@@ -17,8 +16,6 @@ namespace remoting {
PepperView::PepperView(ChromotingInstance* instance)
: instance_(instance),
- backing_store_width_(0),
- backing_store_height_(0),
viewport_x_(0),
viewport_y_(0),
viewport_width_(0),
@@ -63,13 +60,13 @@ void PepperView::Paint() {
} else if (frame_) {
uint32_t* frame_data =
reinterpret_cast<uint32_t*>(frame_->data(media::VideoFrame::kRGBPlane));
- int max_height = std::min(backing_store_height_, image.size().height());
- int max_width = std::min(backing_store_width_, image.size().width());
+ int max_height = std::min(frame_height_, image.size().height());
+ int max_width = std::min(frame_width_, image.size().width());
for (int y = 0; y < max_height; y++) {
for (int x = 0; x < max_width; x++) {
// Force alpha to be set to 255.
*image.GetAddr32(pp::Point(x, y)) =
- frame_data[y*backing_store_width_ + x] | 0xFF000000;
+ frame_data[y*frame_width_ + x] | 0xFF000000;
}
}
} else {
@@ -135,8 +132,11 @@ void PepperView::SetHostScreenSize(int width, int height) {
return;
}
- backing_store_width_ = width;
- backing_store_height_ = height;
+ frame_width_ = width;
+ frame_height_ = height;
+
+ // Reset |frame_| - it will be recreated by the next update stream.
+ frame_ = NULL;
}
void PepperView::HandleBeginUpdateStream(HostMessage* msg) {
@@ -149,24 +149,14 @@ void PepperView::HandleBeginUpdateStream(HostMessage* msg) {
scoped_ptr<HostMessage> deleter(msg);
- // TODO(hclam): Use the information from the message to create the decoder.
- // We lazily construct the decoder.
- if (!decoder_.get()) {
- decoder_.reset(new DecoderZlib());
- }
-
+ // Make sure the |frame_| is initialized.
if (!frame_) {
media::VideoFrame::CreateFrame(media::VideoFrame::RGB32,
- backing_store_width_,
- backing_store_height_,
+ frame_width_, frame_height_,
base::TimeDelta(), base::TimeDelta(),
&frame_);
+ CHECK(frame_);
}
-
- // Tell the decoder to do start decoding.
- decoder_->BeginDecode(frame_, &update_rects_,
- NewRunnableMethod(this, &PepperView::OnPartialDecodeDone),
- NewRunnableMethod(this, &PepperView::OnDecodeDone));
}
void PepperView::HandleUpdateStreamPacket(HostMessage* msg) {
@@ -177,7 +167,14 @@ void PepperView::HandleUpdateStreamPacket(HostMessage* msg) {
return;
}
- decoder_->PartialDecode(msg);
+ // Lazily initialize the decoder.
+ SetupDecoder(msg->update_stream_packet().begin_rect().encoding());
+ if (!decoder_->IsStarted()) {
+ BeginDecoding(NewRunnableMethod(this, &PepperView::OnPartialDecodeDone),
+ NewRunnableMethod(this, &PepperView::OnDecodeDone));
+ }
+
+ Decode(msg);
}
void PepperView::HandleEndUpdateStream(HostMessage* msg) {
@@ -189,7 +186,7 @@ void PepperView::HandleEndUpdateStream(HostMessage* msg) {
}
scoped_ptr<HostMessage> deleter(msg);
- decoder_->EndDecode();
+ EndDecoding();
}
void PepperView::OnPaintDone() {
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index bb4557b..d134207 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -17,14 +17,12 @@
#include "base/scoped_ptr.h"
#include "base/task.h"
#include "media/base/video_frame.h"
-#include "remoting/base/decoder.h"
#include "remoting/client/chromoting_view.h"
#include "third_party/ppapi/cpp/device_context_2d.h"
namespace remoting {
class ChromotingInstance;
-class Decoder;
class PepperView : public ChromotingView {
public:
@@ -60,9 +58,6 @@ class PepperView : public ChromotingView {
pp::DeviceContext2D device_context_;
- int backing_store_width_;
- int backing_store_height_;
-
int viewport_x_;
int viewport_y_;
int viewport_width_;
@@ -71,12 +66,6 @@ class PepperView : public ChromotingView {
bool is_static_fill_;
uint32 static_fill_color_;
- scoped_refptr<media::VideoFrame> frame_;
- UpdatedRects update_rects_;
- UpdatedRects all_update_rects_;
-
- scoped_ptr<Decoder> decoder_;
-
DISALLOW_COPY_AND_ASSIGN(PepperView);
};