Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Unified Diff: remoting/client/plugin/pepper_view.cc

Issue 18233015: Abstract PPAPI's ImageData behind webrtc::DesktopFrame interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/client/plugin/pepper_view.cc
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 8af4fa3f9393bbec5bb3d703a14b5dd239791c6c..cb0e65faa38a170ad36a870d4c78b57c7ee3e5ca 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -13,7 +13,6 @@
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/graphics_2d_dev.h"
#include "ppapi/cpp/dev/view_dev.h"
-#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
@@ -22,6 +21,7 @@
#include "remoting/client/client_context.h"
#include "remoting/client/frame_producer.h"
#include "remoting/client/plugin/chromoting_instance.h"
+#include "remoting/client/plugin/pepper_image_buffer.h"
#include "remoting/client/plugin/pepper_util.h"
using base::Passed;
@@ -139,7 +139,7 @@ void PepperView::SetView(const pp::View& view) {
void PepperView::ApplyBuffer(const SkISize& view_size,
const SkIRect& clip_area,
- pp::ImageData* buffer,
+ ImageBuffer* buffer,
const SkRegion& region) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
@@ -160,13 +160,13 @@ void PepperView::ApplyBuffer(const SkISize& view_size,
}
}
-void PepperView::ReturnBuffer(pp::ImageData* buffer) {
+void PepperView::ReturnBuffer(ImageBuffer* buffer) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
// Reuse the buffer if it is large enough, otherwise drop it on the floor
// and allocate a new one.
- if (buffer->size().width() >= clip_area_.width() &&
- buffer->size().height() >= clip_area_.height()) {
+ if (buffer->width() >= clip_area_.width() &&
+ buffer->height() >= clip_area_.height()) {
producer_->DrawBuffer(buffer);
} else {
FreeBuffer(buffer);
@@ -188,17 +188,16 @@ void PepperView::SetSourceSize(const SkISize& source_size,
instance_->SetDesktopSize(source_size, source_dpi);
}
-pp::ImageData* PepperView::AllocateBuffer() {
+ImageBuffer* PepperView::AllocateBuffer() {
if (buffers_.size() >= kMaxPendingBuffersCount)
return NULL;
- pp::Size pp_size = pp::Size(clip_area_.width(), clip_area_.height());
- if (pp_size.IsEmpty())
+ if (clip_area_.width()==0 || clip_area_.height()==0)
return NULL;
// Create an image buffer of the required size, but don't zero it.
- pp::ImageData* buffer = new pp::ImageData(
- instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL, pp_size, false);
+ ImageBuffer* buffer = new PepperImageBuffer(
+ instance_, clip_area_.width(), clip_area_.height());
if (buffer->is_null()) {
LOG(WARNING) << "Not enough memory for frame buffers.";
delete buffer;
@@ -209,7 +208,7 @@ pp::ImageData* PepperView::AllocateBuffer() {
return buffer;
}
-void PepperView::FreeBuffer(pp::ImageData* buffer) {
+void PepperView::FreeBuffer(ImageBuffer* buffer) {
DCHECK(std::find(buffers_.begin(), buffers_.end(), buffer) != buffers_.end());
buffers_.remove(buffer);
@@ -217,7 +216,7 @@ void PepperView::FreeBuffer(pp::ImageData* buffer) {
}
void PepperView::InitiateDrawing() {
- pp::ImageData* buffer = AllocateBuffer();
+ ImageBuffer* buffer = AllocateBuffer();
while (buffer) {
producer_->DrawBuffer(buffer);
buffer = AllocateBuffer();
@@ -225,7 +224,7 @@ void PepperView::InitiateDrawing() {
}
void PepperView::FlushBuffer(const SkIRect& clip_area,
- pp::ImageData* buffer,
+ ImageBuffer* buffer,
const SkRegion& region) {
// Defer drawing if the flush is already in progress.
if (flush_pending_) {
@@ -257,7 +256,7 @@ void PepperView::FlushBuffer(const SkIRect& clip_area,
// Pepper Graphics 2D has a strange and badly documented API that the
// point here is the offset from the source rect. Why?
graphics2d_.PaintImageData(
- *buffer,
+ static_cast<PepperImageBuffer*>(buffer)->data_object(),
pp::Point(clip_area.left(), clip_area.top()),
pp::Rect(rect.left(), rect.top(), rect.width(), rect.height()));
}
@@ -286,7 +285,7 @@ void PepperView::FlushBuffer(const SkIRect& clip_area,
}
void PepperView::OnFlushDone(base::Time paint_start,
- pp::ImageData* buffer,
+ ImageBuffer* buffer,
int result) {
DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
DCHECK(flush_pending_);

Powered by Google App Engine
This is Rietveld 408576698