diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-24 03:23:23 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-24 03:23:23 +0000 |
commit | 22f58a413b507463f97804a947c732d9a1c7eec6 (patch) | |
tree | eb5e11bb4ab6b25b220648cb346d2a6d712de133 /remoting | |
parent | 4466cbde3ee2d518081872862e3cfe741731540e (diff) | |
download | chromium_src-22f58a413b507463f97804a947c732d9a1c7eec6.zip chromium_src-22f58a413b507463f97804a947c732d9a1c7eec6.tar.gz chromium_src-22f58a413b507463f97804a947c732d9a1c7eec6.tar.bz2 |
Revert 118790 - Compile error due to missing operator== on SkRegion
Replace RectVectors with SkRegions in Decoder.
BUG=105401
Review URL: http://codereview.chromium.org/9277001
TBR=wez@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9146030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118793 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/base/codec_test.cc | 74 | ||||
-rw-r--r-- | remoting/base/decoder.h | 24 | ||||
-rw-r--r-- | remoting/base/decoder_row_based.cc | 12 | ||||
-rw-r--r-- | remoting/base/decoder_row_based.h | 6 | ||||
-rw-r--r-- | remoting/base/decoder_vp8.cc | 57 | ||||
-rw-r--r-- | remoting/base/decoder_vp8.h | 25 | ||||
-rw-r--r-- | remoting/client/frame_consumer.h | 10 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.cc | 8 | ||||
-rw-r--r-- | remoting/client/frame_consumer_proxy.h | 4 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.cc | 12 | ||||
-rw-r--r-- | remoting/client/plugin/pepper_view.h | 6 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.cc | 30 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.h | 4 |
13 files changed, 142 insertions, 130 deletions
diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc index 81f0db8..efe7055 100644 --- a/remoting/base/codec_test.cc +++ b/remoting/base/codec_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -132,8 +132,8 @@ class DecoderTester { } void Reset() { - expected_region_.setEmpty(); - update_region_.setEmpty(); + rects_.clear(); + update_rects_.clear(); } void ReceivedPacket(VideoPacket* packet) { @@ -142,7 +142,7 @@ class DecoderTester { ASSERT_NE(Decoder::DECODE_ERROR, result); if (result == Decoder::DECODE_DONE) { - decoder_->GetUpdatedRegion(&update_region_); + decoder_->GetUpdatedRects(&update_rects_); } } @@ -155,9 +155,7 @@ class DecoderTester { } void AddRects(const SkIRect* rects, int count) { - SkRegion new_rects; - new_rects.setRects(rects, count); - expected_region_.op(new_rects, SkRegion::kUnion_Op); + rects_.insert(rects_.begin() + rects_.size(), rects, rects + count); } void VerifyResults() { @@ -166,17 +164,19 @@ class DecoderTester { ASSERT_TRUE(capture_data_.get()); - // Test the content of the update region. - EXPECT_EQ(expected_region_, update_region_); - for (SkRegion::Iterator i(update_region_); !i.done(); i.next()) { + // Test the content of the update rect. + ASSERT_EQ(rects_.size(), update_rects_.size()); + for (size_t i = 0; i < update_rects_.size(); ++i) { + EXPECT_EQ(rects_[i], update_rects_[i]); + EXPECT_EQ(frame_->stride(0), capture_data_->data_planes().strides[0]); const int stride = frame_->stride(0); - const int offset = stride * i.rect().top() + - kBytesPerPixel * i.rect().left(); + const int offset = stride * update_rects_[i].fTop + + kBytesPerPixel * update_rects_[i].fLeft; const uint8* original = capture_data_->data_planes().data[0] + offset; const uint8* decoded = frame_->data(0) + offset; - const int row_size = kBytesPerPixel * i.rect().width(); - for (int y = 0; y < i.rect().height(); ++y) { + const int row_size = kBytesPerPixel * update_rects_[i].width(); + for (int y = 0; y < update_rects_[i].height(); ++y) { EXPECT_EQ(0, memcmp(original, decoded, row_size)) << "Row " << y << " is different"; original += stride; @@ -187,8 +187,8 @@ class DecoderTester { private: bool strict_; - SkRegion expected_region_; - SkRegion update_region_; + std::deque<SkIRect> rects_; + RectVector update_rects_; Decoder* decoder_; scoped_refptr<media::VideoFrame> frame_; scoped_refptr<CaptureData> capture_data_; @@ -292,24 +292,28 @@ void TestEncoder(Encoder* encoder, bool strict) { TestEncodingRects(encoder, &tester, data, kTestRects + 3, 2); } -static void TestEncodeDecodeRects(Encoder* encoder, - EncoderTester* encoder_tester, - DecoderTester* decoder_tester, - scoped_refptr<CaptureData> data, - const SkIRect* rects, int count) { - data->mutable_dirty_region().setRects(rects, count); +static void TestEncodingRects(Encoder* encoder, + EncoderTester* encoder_tester, + DecoderTester* decoder_tester, + scoped_refptr<CaptureData> data, + const SkIRect* rects, int count) { + data->mutable_dirty_region().setEmpty(); + for (int i = 0; i < count; ++i) { + data->mutable_dirty_region().op(rects[i], SkRegion::kUnion_Op); + } encoder_tester->AddRects(rects, count); decoder_tester->AddRects(rects, count); - // Generate random data for the updated region. + // Generate random data for the updated rects. srand(0); for (int i = 0; i < count; ++i) { + const SkIRect& rect = rects[i]; const int bytes_per_pixel = GetBytesPerPixel(data->pixel_format()); - const int row_size = bytes_per_pixel * rects[i].width(); + const int row_size = bytes_per_pixel * rect.width(); uint8* memory = data->data_planes().data[0] + - data->data_planes().strides[0] * rects[i].top() + - bytes_per_pixel * rects[i].left(); - for (int y = 0; y < rects[i].height(); ++y) { + data->data_planes().strides[0] * rect.fTop + + bytes_per_pixel * rect.fLeft; + for (int y = 0; y < rect.height(); ++y) { for (int x = 0; x < row_size; ++x) memory[x] = rand() % 256; memory += data->data_planes().strides[0]; @@ -338,14 +342,14 @@ void TestEncoderDecoder(Encoder* encoder, Decoder* decoder, bool strict) { decoder_tester.set_capture_data(data); encoder_tester.set_decoder_tester(&decoder_tester); - TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, - kTestRects, 1); - TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, - kTestRects + 1, 1); - TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, - kTestRects + 2, 1); - TestEncodeDecodeRects(encoder, &encoder_tester, &decoder_tester, data, - kTestRects + 3, 2); + TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, + kTestRects, 1); + TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, + kTestRects + 1, 1); + TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, + kTestRects + 2, 1); + TestEncodingRects(encoder, &encoder_tester, &decoder_tester, data, + kTestRects + 3, 2); } } // namespace remoting diff --git a/remoting/base/decoder.h b/remoting/base/decoder.h index 9efc17e..dd37757 100644 --- a/remoting/base/decoder.h +++ b/remoting/base/decoder.h @@ -1,17 +1,21 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef REMOTING_BASE_DECODER_H_ #define REMOTING_BASE_DECODER_H_ +#include <vector> + #include "base/memory/scoped_ptr.h" #include "media/base/video_frame.h" #include "remoting/proto/video.pb.h" -#include "third_party/skia/include/core/SkRegion.h" +#include "third_party/skia/include/core/SkRect.h" namespace remoting { +typedef std::vector<SkIRect> RectVector; + // Interface for a decoder that takes a stream of bytes from the network and // outputs frames of data. // @@ -38,10 +42,10 @@ class Decoder { // Feeds more data into the decoder. virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; - // Returns the region affected by the most recent frame. Can be called only + // Returns rects that were updated in the last frame. Can be called only // after DecodePacket returned DECODE_DONE. Caller keeps ownership of - // |region|. - virtual void GetUpdatedRegion(SkRegion* region) = 0; + // |rects|. |rects| is kept empty if whole screen needs to be updated. + virtual void GetUpdatedRects(RectVector* rects) = 0; // Reset the decoder to an uninitialized state. Release all references to // the initialized |frame|. Initialize() must be called before the decoder @@ -61,12 +65,14 @@ class Decoder { // Set the clipping rectangle to the decoder. Decoder should respect this and // only output changes in this rectangle. The new clipping rectangle will be // effective on the next decoded video frame. + // + // When scaling is enabled clipping rectangles are ignored. virtual void SetClipRect(const SkIRect& clip_rect) {} - // Force decoder to output a frame based on the specified |region| of the - // most recently decoded video frame. |region| is expressed in video frame - // rather than output coordinates. - virtual void RefreshRegion(const SkRegion& region) {} + // Force decoder to output a video frame with content in |rects| using the + // last decoded video frame. |rects| are expressed in video frame rather + // than output coordinates. + virtual void RefreshRects(const RectVector& rects) {} }; } // namespace remoting diff --git a/remoting/base/decoder_row_based.cc b/remoting/base/decoder_row_based.cc index 5c95991..da65079 100644 --- a/remoting/base/decoder_row_based.cc +++ b/remoting/base/decoder_row_based.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -44,7 +44,7 @@ void DecoderRowBased::Reset() { frame_ = NULL; decompressor_->Reset(); state_ = kUninitialized; - updated_region_.setEmpty(); + updated_rects_.clear(); } bool DecoderRowBased::IsReadyForData() { @@ -128,7 +128,7 @@ Decoder::DecodeResult DecoderRowBased::DecodePacket(const VideoPacket* packet) { return DECODE_ERROR; } - updated_region_.op(clip_, SkRegion::kUnion_Op); + updated_rects_.push_back(clip_); decompressor_->Reset(); } @@ -186,9 +186,9 @@ void DecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) { return; } -void DecoderRowBased::GetUpdatedRegion(SkRegion* region) { - region->swap(updated_region_); - updated_region_.setEmpty(); +void DecoderRowBased::GetUpdatedRects(RectVector* rects) { + rects->swap(updated_rects_); + updated_rects_.clear(); } VideoPacketFormat::Encoding DecoderRowBased::Encoding() { diff --git a/remoting/base/decoder_row_based.h b/remoting/base/decoder_row_based.h index 183086c..7086c7b 100644 --- a/remoting/base/decoder_row_based.h +++ b/remoting/base/decoder_row_based.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,7 +22,7 @@ class DecoderRowBased : public Decoder { virtual bool IsReadyForData() OVERRIDE; virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; - virtual void GetUpdatedRegion(SkRegion* region) OVERRIDE; + virtual void GetUpdatedRects(RectVector* rects) OVERRIDE; virtual void Reset() OVERRIDE; virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; @@ -63,7 +63,7 @@ class DecoderRowBased : public Decoder { // The current row in the rect that we are updaing. int row_y_; - SkRegion updated_region_; + RectVector updated_rects_; DISALLOW_COPY_AND_ASSIGN(DecoderRowBased); }; diff --git a/remoting/base/decoder_vp8.cc b/remoting/base/decoder_vp8.cc index 40746913..d0e3785 100644 --- a/remoting/base/decoder_vp8.cc +++ b/remoting/base/decoder_vp8.cc @@ -92,22 +92,22 @@ Decoder::DecodeResult DecoderVp8::DecodePacket(const VideoPacket* packet) { } last_image_ = image; - SkRegion region; + RectVector rects; + rects.reserve(packet->dirty_rects_size()); for (int i = 0; i < packet->dirty_rects_size(); ++i) { Rect remoting_rect = packet->dirty_rects(i); - SkIRect rect = SkIRect::MakeXYWH(remoting_rect.x(), - remoting_rect.y(), - remoting_rect.width(), - remoting_rect.height()); - region.op(rect, SkRegion::kUnion_Op); + rects.push_back(SkIRect::MakeXYWH(remoting_rect.x(), + remoting_rect.y(), + remoting_rect.width(), + remoting_rect.height())); } - RefreshRegion(region); + RefreshRects(rects); return DECODE_DONE; } -void DecoderVp8::GetUpdatedRegion(SkRegion* region) { - region->swap(updated_region_); +void DecoderVp8::GetUpdatedRects(RectVector* rects) { + rects->swap(updated_rects_); } void DecoderVp8::Reset() { @@ -131,7 +131,7 @@ void DecoderVp8::SetClipRect(const SkIRect& clip_rect) { clip_rect_ = clip_rect; } -void DecoderVp8::RefreshRegion(const SkRegion& region) { +void DecoderVp8::RefreshRects(const RectVector& rects) { // TODO(wez): Fix the rest of the decode pipeline not to assume the frame // size is the host dimensions, since it's not when scaling. If the host // gets smaller, then the output size will be too big and we'll overrun the @@ -142,11 +142,10 @@ void DecoderVp8::RefreshRegion(const SkRegion& region) { if (output_size_.height() > static_cast<int>(frame_->height())) output_size_.set(output_size_.width(), frame_->height()); - if (!DoScaling()) { - ConvertRegion(region, &updated_region_); - } else { - ScaleAndConvertRegion(region, &updated_region_); - } + if (!DoScaling()) + ConvertRects(rects, &updated_rects_); + else + ScaleAndConvertRects(rects, &updated_rects_); } bool DecoderVp8::DoScaling() const { @@ -154,12 +153,12 @@ bool DecoderVp8::DoScaling() const { return !output_size_.equals(last_image_->d_w, last_image_->d_h); } -void DecoderVp8::ConvertRegion(const SkRegion& input_region, - SkRegion* output_region) { +void DecoderVp8::ConvertRects(const RectVector& input_rects, + RectVector* output_rects) { if (!last_image_) return; - output_region->setEmpty(); + output_rects->clear(); // Clip based on both the output dimensions and Pepper clip rect. // ConvertYUVToRGB32WithRect() requires even X and Y coordinates, so we align @@ -172,11 +171,12 @@ void DecoderVp8::ConvertRegion(const SkRegion& input_region, uint8* output_rgb_buf = frame_->data(media::VideoFrame::kRGBPlane); const int output_stride = frame_->stride(media::VideoFrame::kRGBPlane); + output_rects->reserve(input_rects.size()); - for (SkRegion::Iterator i(input_region); !i.done(); i.next()) { + for (size_t i = 0; i < input_rects.size(); ++i) { // Align the rectangle so the top-left coordinates are even, for // ConvertYUVToRGB32WithRect(). - SkIRect dest_rect(AlignRect(i.rect())); + SkIRect dest_rect(AlignRect(input_rects[i])); // Clip the rectangle, preserving alignment since |clip_rect| is aligned. if (!dest_rect.intersect(clip_rect)) @@ -191,19 +191,19 @@ void DecoderVp8::ConvertRegion(const SkRegion& input_region, last_image_->stride[1], output_stride); - output_region->op(dest_rect, SkRegion::kUnion_Op); + output_rects->push_back(dest_rect); } } -void DecoderVp8::ScaleAndConvertRegion(const SkRegion& input_region, - SkRegion* output_region) { +void DecoderVp8::ScaleAndConvertRects(const RectVector& input_rects, + RectVector* output_rects) { if (!last_image_) return; DCHECK(output_size_.width() <= static_cast<int>(frame_->width())); DCHECK(output_size_.height() <= static_cast<int>(frame_->height())); - output_region->setEmpty(); + output_rects->clear(); // Clip based on both the output dimensions and Pepper clip rect. SkIRect clip_rect = clip_rect_; @@ -214,9 +214,11 @@ void DecoderVp8::ScaleAndConvertRegion(const SkRegion& input_region, uint8* output_rgb_buf = frame_->data(media::VideoFrame::kRGBPlane); const int output_stride = frame_->stride(media::VideoFrame::kRGBPlane); - for (SkRegion::Iterator i(input_region); !i.done(); i.next()) { + output_rects->reserve(input_rects.size()); + + for (size_t i = 0; i < input_rects.size(); ++i) { // Determine the scaled area affected by this rectangle changing. - SkIRect output_rect = ScaleRect(i.rect(), image_size, output_size_); + SkIRect output_rect = ScaleRect(input_rects[i], image_size, output_size_); if (!output_rect.intersect(clip_rect)) continue; @@ -236,8 +238,7 @@ void DecoderVp8::ScaleAndConvertRegion(const SkRegion& input_region, last_image_->stride[0], last_image_->stride[1], output_stride); - - output_region->op(output_rect, SkRegion::kUnion_Op); + output_rects->push_back(output_rect); } } diff --git a/remoting/base/decoder_vp8.h b/remoting/base/decoder_vp8.h index 76fd547..a89991c 100644 --- a/remoting/base/decoder_vp8.h +++ b/remoting/base/decoder_vp8.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,13 +20,13 @@ class DecoderVp8 : public Decoder { // Decoder implementations. virtual void Initialize(scoped_refptr<media::VideoFrame> frame) OVERRIDE; virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; - virtual void GetUpdatedRegion(SkRegion* region) OVERRIDE; + virtual void GetUpdatedRects(RectVector* rects) OVERRIDE; virtual bool IsReadyForData() OVERRIDE; virtual void Reset() OVERRIDE; virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; virtual void SetOutputSize(const SkISize& size) OVERRIDE; virtual void SetClipRect(const SkIRect& clip_rect) OVERRIDE; - virtual void RefreshRegion(const SkRegion& region) OVERRIDE; + virtual void RefreshRects(const RectVector& rects) OVERRIDE; private: enum State { @@ -38,15 +38,16 @@ class DecoderVp8 : public Decoder { // Return true if scaling is enabled bool DoScaling() const; - // Perform color space conversion on the specified region. - // Writes the updated region to |output_region|. - void ConvertRegion(const SkRegion& region, - SkRegion* output_region); + // Perform color space conversion on the specified rectangles. + // Write the updated rectangles to |output_rects|. + void ConvertRects(const RectVector& rects, + RectVector* output_rects); // Perform scaling and color space conversion on the specified - // region. Writes the updated rectangles to |output_region|. - void ScaleAndConvertRegion(const SkRegion& region, - SkRegion* output_region); + // rectangles. + // Write the updated rectangles to |output_rects|. + void ScaleAndConvertRects(const RectVector& rects, + RectVector* output_rects); // The internal state of the decoder. State state_; @@ -59,8 +60,8 @@ class DecoderVp8 : public Decoder { // Pointer to the last decoded image. vpx_image_t* last_image_; - // The region updated by the most recent decode. - SkRegion updated_region_; + // Record the updated rects in the last decode. + RectVector updated_rects_; // Clipping rect for the output of the decoder. SkIRect clip_rect_; diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h index de56d81..65b0c64 100644 --- a/remoting/client/frame_consumer.h +++ b/remoting/client/frame_consumer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,13 +40,13 @@ class FrameConsumer { virtual void ReleaseFrame(media::VideoFrame* frame) = 0; // OnPartialFrameOutput() is called every time at least one rectangle of - // output is produced. The |frame| is guaranteed to have valid data for all - // of |region|. + // output is produced. The |frame| is guaranteed to have valid data for every + // region included in the |rects| list. // - // Both |frame| and |region| are guaranteed to be valid until the |done| + // Both |frame| and |rects| are guaranteed to be valid until the |done| // callback is invoked. virtual void OnPartialFrameOutput(media::VideoFrame* frame, - SkRegion* region, + RectVector* rects, const base::Closure& done) = 0; private: diff --git a/remoting/client/frame_consumer_proxy.cc b/remoting/client/frame_consumer_proxy.cc index 65b84ed..3f7890a 100644 --- a/remoting/client/frame_consumer_proxy.cc +++ b/remoting/client/frame_consumer_proxy.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -48,17 +48,17 @@ void FrameConsumerProxy::ReleaseFrame(media::VideoFrame* frame) { } void FrameConsumerProxy::OnPartialFrameOutput(media::VideoFrame* frame, - SkRegion* region, + RectVector* rects, const base::Closure& done) { if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( &FrameConsumerProxy::OnPartialFrameOutput, this, - make_scoped_refptr(frame), region, done)); + make_scoped_refptr(frame), rects, done)); return; } if (frame_consumer_) - frame_consumer_->OnPartialFrameOutput(frame, region, done); + frame_consumer_->OnPartialFrameOutput(frame, rects, done); } void FrameConsumerProxy::Detach() { diff --git a/remoting/client/frame_consumer_proxy.h b/remoting/client/frame_consumer_proxy.h index d7dd4b2..d3a88cc 100644 --- a/remoting/client/frame_consumer_proxy.h +++ b/remoting/client/frame_consumer_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,7 @@ class FrameConsumerProxy const base::Closure& done) OVERRIDE; virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; virtual void OnPartialFrameOutput(media::VideoFrame* frame, - SkRegion* region, + RectVector* rects, const base::Closure& done) OVERRIDE; // Detaches from |frame_consumer_|, ensuring no further calls reach it. diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc index fe404c2..d8a776c 100644 --- a/remoting/client/plugin/pepper_view.cc +++ b/remoting/client/plugin/pepper_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -110,7 +110,7 @@ void PepperView::SetHostSize(const SkISize& host_size) { host_size.width(), host_size.height()); } -void PepperView::PaintFrame(media::VideoFrame* frame, const SkRegion& region) { +void PepperView::PaintFrame(media::VideoFrame* frame, RectVector* rects) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); SetHostSize(SkISize::Make(frame->width(), frame->height())); @@ -124,8 +124,8 @@ void PepperView::PaintFrame(media::VideoFrame* frame, const SkRegion& region) { // Copy updated regions to the backing store and then paint the regions. bool changes_made = false; - for (SkRegion::Iterator i(region); !i.done(); i.next()) - changes_made |= PaintRect(frame, i.rect()); + for (size_t i = 0; i < rects->size(); ++i) + changes_made |= PaintRect(frame, (*rects)[i]); if (changes_made) FlushGraphics(start_time); @@ -313,13 +313,13 @@ void PepperView::ReleaseFrame(media::VideoFrame* frame) { } void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, - SkRegion* region, + RectVector* rects, const base::Closure& done) { DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); // TODO(ajwong): Clean up this API to be async so we don't need to use a // member variable as a hack. - PaintFrame(frame, *region); + PaintFrame(frame, rects); done.Run(); } diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h index 426ced0..eab7f59 100644 --- a/remoting/client/plugin/pepper_view.h +++ b/remoting/client/plugin/pepper_view.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -48,7 +48,7 @@ class PepperView : public ChromotingView, const base::Closure& done) OVERRIDE; virtual void ReleaseFrame(media::VideoFrame* frame) OVERRIDE; virtual void OnPartialFrameOutput(media::VideoFrame* frame, - SkRegion* region, + RectVector* rects, const base::Closure& done) OVERRIDE; // Sets the display size of this view. Returns true if plugin size has @@ -69,7 +69,7 @@ class PepperView : public ChromotingView, // Set the dimension of the entire host screen. void SetHostSize(const SkISize& host_size); - void PaintFrame(media::VideoFrame* frame, const SkRegion& region); + void PaintFrame(media::VideoFrame* frame, RectVector* rects); // Render the rectangle of |frame| to the backing store. // Returns true if this rectangle is not clipped. diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc index 673c2a0..3ce8b65 100644 --- a/remoting/client/rectangle_update_decoder.cc +++ b/remoting/client/rectangle_update_decoder.cc @@ -140,7 +140,7 @@ void RectangleUpdateDecoder::SetOutputSize(const SkISize& size) { // TODO(wez): Refresh the frame only if the ratio has changed. if (frame_) { SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height()); - refresh_region_.op(frame_rect, SkRegion::kUnion_Op); + refresh_rects_.push_back(frame_rect); } // TODO(hclam): If the scale ratio has changed we should reallocate a @@ -166,7 +166,7 @@ void RectangleUpdateDecoder::UpdateClipRect(const SkIRect& new_clip_rect) { // TODO(wez): Only refresh newly-exposed portions of the frame. if (frame_) { SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height()); - refresh_region_.op(frame_rect, SkRegion::kUnion_Op); + refresh_rects_.push_back(frame_rect); } clip_rect_ = new_clip_rect; @@ -188,9 +188,9 @@ void RectangleUpdateDecoder::RefreshFullFrame() { if (!frame_ || !decoder_.get()) return; - SkIRect frame_rect = SkIRect::MakeWH(frame_->width(), frame_->height()); - refresh_region_.op(frame_rect, SkRegion::kUnion_Op); - + refresh_rects_.push_back( + SkIRect::MakeWH(static_cast<int>(frame_->width()), + static_cast<int>(frame_->height()))); DoRefresh(); } @@ -200,33 +200,33 @@ void RectangleUpdateDecoder::SubmitToConsumer() { if (!frame_) return; - SkRegion* dirty_region = new SkRegion; - decoder_->GetUpdatedRegion(dirty_region); + RectVector* dirty_rects = new RectVector(); + decoder_->GetUpdatedRects(dirty_rects); - consumer_->OnPartialFrameOutput(frame_, dirty_region, base::Bind( - &RectangleUpdateDecoder::OnFrameConsumed, this, dirty_region)); + consumer_->OnPartialFrameOutput(frame_, dirty_rects, base::Bind( + &RectangleUpdateDecoder::OnFrameConsumed, this, dirty_rects)); } void RectangleUpdateDecoder::DoRefresh() { DCHECK(message_loop_->BelongsToCurrentThread()); - if (refresh_region_.isEmpty()) + if (refresh_rects_.empty()) return; - decoder_->RefreshRegion(refresh_region_); - refresh_region_.setEmpty(); + decoder_->RefreshRects(refresh_rects_); + refresh_rects_.clear(); SubmitToConsumer(); } -void RectangleUpdateDecoder::OnFrameConsumed(SkRegion* region) { +void RectangleUpdateDecoder::OnFrameConsumed(RectVector* rects) { if (!message_loop_->BelongsToCurrentThread()) { message_loop_->PostTask( FROM_HERE, base::Bind(&RectangleUpdateDecoder::OnFrameConsumed, - this, region)); + this, rects)); return; } - delete region; + delete rects; DoRefresh(); } diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h index e2833c2..4ff4d93 100644 --- a/remoting/client/rectangle_update_decoder.h +++ b/remoting/client/rectangle_update_decoder.h @@ -71,14 +71,14 @@ class RectangleUpdateDecoder : void DoRefresh(); // Callback for FrameConsumer::OnPartialFrameOutput() - void OnFrameConsumed(SkRegion* region); + void OnFrameConsumed(RectVector* rects); scoped_refptr<base::MessageLoopProxy> message_loop_; FrameConsumer* consumer_; SkISize screen_size_; SkIRect clip_rect_; - SkRegion refresh_region_; + RectVector refresh_rects_; scoped_ptr<Decoder> decoder_; bool decoder_needs_reset_; |