Skip to content

Commit

Permalink
Remove unused PPB_Graphics2D_Dev interface
Browse files Browse the repository at this point in the history
This may be revived later to implement fast PDF scrolling but that's too far out so get rid of it for the time being.

BUG=303491
R=jschuh@chromium.org, piman@chromium.org, teravest@chromium.org

Review URL: https://codereview.chromium.org/216213002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261242 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
raymes@google.com committed Apr 3, 2014
1 parent 5b8a865 commit bd51beb
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 841 deletions.
1 change: 0 additions & 1 deletion chrome/browser/component_updater/ppapi_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
#include "ppapi/c/dev/ppb_opengles2ext_dev.h"
Expand Down
98 changes: 13 additions & 85 deletions content/renderer/pepper/pepper_graphics_2d_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ struct PepperGraphics2DHost::QueuedOperation {
PAINT,
SCROLL,
REPLACE,
SET_OFFSET
};

QueuedOperation(Type t)
Expand All @@ -161,9 +160,6 @@ struct PepperGraphics2DHost::QueuedOperation {

// Valid when type == REPLACE.
scoped_refptr<PPB_ImageData_Impl> replace_image;

// Valid when type == SET_OFFSET.
gfx::Point offset;
};

// static
Expand Down Expand Up @@ -196,8 +192,7 @@ PepperGraphics2DHost::PepperGraphics2DHost(RendererPpapiHost* host,
is_always_opaque_(false),
scale_(1.0f),
is_running_in_process_(host->IsRunningInProcess()),
texture_mailbox_modified_(true),
resize_mode_(PP_GRAPHICS2D_DEV_RESIZEMODE_DEFAULT) {}
texture_mailbox_modified_(true) {}

PepperGraphics2DHost::~PepperGraphics2DHost() {
// Unbind from the instance when destroyed if we're still bound.
Expand Down Expand Up @@ -236,18 +231,12 @@ int32_t PepperGraphics2DHost::OnResourceMessageReceived(
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_Graphics2D_ReplaceContents,
OnHostMsgReplaceContents)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(
PpapiHostMsg_Graphics2D_Flush,
OnHostMsgFlush)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_Graphics2D_Dev_SetScale,
PpapiHostMsg_Graphics2D_SetScale,
OnHostMsgSetScale)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_Graphics2D_SetOffset,
OnHostMsgSetOffset)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_Graphics2D_SetResizeMode,
OnHostMsgSetResizeMode)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(
PpapiHostMsg_Graphics2D_ReadImageData,
OnHostMsgReadImageData)
Expand Down Expand Up @@ -397,16 +386,11 @@ void PepperGraphics2DHost::Paint(blink::WebCanvas* canvas,

SkPoint pixel_origin = origin;

gfx::PointF resize_scale(GetResizeScale());
gfx::PointF scale(ScalePoint(resize_scale, scale_));
if ((scale.x() != 1.0f || scale.y() != 1.0f) &&
scale.x() > 0.0f && scale.y() > 0.0f) {
canvas->scale(scale.x(), scale.y());
pixel_origin.set(pixel_origin.x() * (1.0f / scale.x()),
pixel_origin.y() * (1.0f / scale.y()));
if (scale_ != 1.0f && scale_ > 0.0f) {
canvas->scale(scale_, scale_);
pixel_origin.set(pixel_origin.x() * (1.0f / scale_),
pixel_origin.y() * (1.0f / scale_));
}
pixel_origin.offset(SkIntToScalar(plugin_offset_.x()),
SkIntToScalar(plugin_offset_.y()));
canvas->drawBitmap(image, pixel_origin.x(), pixel_origin.y(), &paint);
}

Expand All @@ -421,11 +405,6 @@ void PepperGraphics2DHost::ViewFlushedPaint() {
}
}

void PepperGraphics2DHost::DidChangeView(const ppapi::ViewData& view_data) {
gfx::Size old_plugin_size = current_plugin_size_;
current_plugin_size_ = PP_ToGfxSize(view_data.rect.size);
}

void PepperGraphics2DHost::SetScale(float scale) {
scale_ = scale;
}
Expand All @@ -448,21 +427,6 @@ gfx::Size PepperGraphics2DHost::Size() const {
return gfx::Size(image_data_->width(), image_data_->height());
}

gfx::PointF PepperGraphics2DHost::GetResizeScale() const {
switch (resize_mode_) {
case PP_GRAPHICS2D_DEV_RESIZEMODE_DEFAULT:
return gfx::PointF(1.0f, 1.0f);
case PP_GRAPHICS2D_DEV_RESIZEMODE_STRETCH:
if (flushed_plugin_size_.IsEmpty())
return gfx::PointF(1.0f, 1.0f);
return gfx::PointF(
1.0f * current_plugin_size_.width() / flushed_plugin_size_.width(),
1.0f * current_plugin_size_.height() / flushed_plugin_size_.height());
}
NOTREACHED();
return gfx::PointF(1.0f, 1.0f);
}

int32_t PepperGraphics2DHost::OnHostMsgPaintImageData(
ppapi::host::HostMessageContext* context,
const ppapi::HostResource& image_data,
Expand Down Expand Up @@ -555,19 +519,18 @@ int32_t PepperGraphics2DHost::OnHostMsgReplaceContents(
}

int32_t PepperGraphics2DHost::OnHostMsgFlush(
ppapi::host::HostMessageContext* context,
const ppapi::ViewData& view_data) {
ppapi::host::HostMessageContext* context) {
// Don't allow more than one pending flush at a time.
if (HasPendingFlush())
return PP_ERROR_INPROGRESS;

PP_Resource old_image_data = 0;
flush_reply_context_ = context->MakeReplyMessageContext();
if (is_running_in_process_)
return Flush(NULL, PP_ToGfxSize(view_data.rect.size));
return Flush(NULL);

// Reuse image data when running out of process.
int32_t result = Flush(&old_image_data, PP_ToGfxSize(view_data.rect.size));
int32_t result = Flush(&old_image_data);

if (old_image_data) {
// If the Graphics2D has an old image data it's not using any more, send
Expand All @@ -593,22 +556,6 @@ int32_t PepperGraphics2DHost::OnHostMsgSetScale(
return PP_ERROR_BADARGUMENT;
}

int32_t PepperGraphics2DHost::OnHostMsgSetOffset(
ppapi::host::HostMessageContext* context,
const PP_Point& offset) {
QueuedOperation operation(QueuedOperation::SET_OFFSET);
operation.offset = PP_ToGfxPoint(offset);
queued_operations_.push_back(operation);
return PP_OK;
}

int32_t PepperGraphics2DHost::OnHostMsgSetResizeMode(
ppapi::host::HostMessageContext* context,
PP_Graphics2D_Dev_ResizeMode resize_mode) {
resize_mode_ = resize_mode;
return PP_OK;
}

int32_t PepperGraphics2DHost::OnHostMsgReadImageData(
ppapi::host::HostMessageContext* context,
PP_Resource image,
Expand Down Expand Up @@ -648,15 +595,13 @@ void PepperGraphics2DHost::AttachedToNewLayer() {
texture_mailbox_modified_ = true;
}

int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data,
const gfx::Size& flushed_plugin_size) {
int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) {
bool done_replace_contents = false;
bool no_update_visible = true;
bool is_plugin_visible = true;
for (size_t i = 0; i < queued_operations_.size(); i++) {
QueuedOperation& operation = queued_operations_[i];
gfx::Rect op_rect;
gfx::Rect old_op_rect;
switch (operation.type) {
case QueuedOperation::PAINT:
ExecutePaintImageData(operation.paint_image.get(),
Expand All @@ -680,28 +625,16 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data,
done_replace_contents ? NULL : old_image_data);
done_replace_contents = true;
break;
case QueuedOperation::SET_OFFSET:
old_op_rect = gfx::Rect(plugin_offset_.x(), plugin_offset_.y(),
image_data_->width(), image_data_->height());
plugin_offset_ = operation.offset;
// The offset is applied below for |op_rect|.
op_rect = gfx::Rect(image_data_->width(), image_data_->height());
break;
}

op_rect.Offset(plugin_offset_.x(), plugin_offset_.y());

// For correctness with accelerated compositing, we must issue an invalidate
// on the full op_rect even if it is partially or completely off-screen.
// However, if we issue an invalidate for a clipped-out region, WebKit will
// do nothing and we won't get any ViewFlushedPaint calls, leaving our
// callback stranded. So we still need to check whether the repainted area
// is visible to determine how to deal with the callback.
if (bound_instance_ && (!op_rect.IsEmpty() || !old_op_rect.IsEmpty())) {
if (bound_instance_ && !op_rect.IsEmpty()) {
gfx::Point scroll_delta(operation.scroll_dx, operation.scroll_dy);
if (!ConvertToLogicalPixels(scale_, &old_op_rect, NULL)) {
NOTREACHED();
}
if (!ConvertToLogicalPixels(scale_,
&op_rect,
operation.type == QueuedOperation::SCROLL ?
Expand All @@ -715,8 +648,7 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data,

// Set |no_update_visible| to false if the change overlaps the visible
// area.
if (!gfx::IntersectRects(clip, op_rect).IsEmpty() ||
!gfx::IntersectRects(clip, old_op_rect).IsEmpty()) {
if (!gfx::IntersectRects(clip, op_rect).IsEmpty()) {
no_update_visible = false;
}

Expand All @@ -725,19 +657,15 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data,
if (operation.type == QueuedOperation::SCROLL) {
bound_instance_->ScrollRect(scroll_delta.x(), scroll_delta.y(),
op_rect);
DCHECK(old_op_rect.IsEmpty());
} else {
if (!op_rect.IsEmpty())
bound_instance_->InvalidateRect(op_rect);
if (!old_op_rect.IsEmpty())
bound_instance_->InvalidateRect(old_op_rect);
}
texture_mailbox_modified_ = true;
}
}
queued_operations_.clear();

flushed_plugin_size_ = flushed_plugin_size;
if (!bound_instance_) {
// As promised in the API, we always schedule callback when unbound.
ScheduleOffscreenFlushAck();
Expand Down
36 changes: 3 additions & 33 deletions content/renderer/pepper/pepper_graphics_2d_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "content/common/content_export.h"
#include "ppapi/c/dev/ppb_graphics_2d_dev.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "ppapi/host/host_message_context.h"
#include "ppapi/host/resource_host.h"
Expand All @@ -33,7 +32,7 @@ struct ViewData;
}

namespace content {

class PepperPluginInstanceImpl;
class PPB_ImageData_Impl;
class RendererPpapiHost;
Expand Down Expand Up @@ -80,20 +79,12 @@ class CONTENT_EXPORT PepperGraphics2DHost
void ViewInitiatedPaint();
void ViewFlushedPaint();

void DidChangeView(const ppapi::ViewData& view_data);

void SetScale(float scale);
float GetScale() const;
bool IsAlwaysOpaque() const;
PPB_ImageData_Impl* ImageData();
gfx::Size Size() const;

// The amount to resize the backing store by when painting to the canvas.
// This is used to stretch the backing store when resizing the plugin element.
gfx::PointF GetResizeScale() const;
// The offset of the backing store into the plugin element.
gfx::Point plugin_offset() const { return plugin_offset_; }

private:
PepperGraphics2DHost(RendererPpapiHost* host,
PP_Instance instance,
Expand All @@ -115,22 +106,16 @@ class CONTENT_EXPORT PepperGraphics2DHost
const PP_Point& amount);
int32_t OnHostMsgReplaceContents(ppapi::host::HostMessageContext* context,
const ppapi::HostResource& image_data);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context,
const ppapi::ViewData& view_data);
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgSetScale(ppapi::host::HostMessageContext* context,
float scale);
int32_t OnHostMsgSetOffset(ppapi::host::HostMessageContext* context,
const PP_Point& offset);
int32_t OnHostMsgSetResizeMode(ppapi::host::HostMessageContext* context,
PP_Graphics2D_Dev_ResizeMode resize_mode);
int32_t OnHostMsgReadImageData(ppapi::host::HostMessageContext* context,
PP_Resource image,
const PP_Point& top_left);

// If |old_image_data| is not NULL, a previous used ImageData object will be
// reused. This is used by ReplaceContents.
int32_t Flush(PP_Resource* old_image_data,
const gfx::Size& flushed_plugin_size);
int32_t Flush(PP_Resource* old_image_data);

// Called internally to execute the different queued commands. The
// parameters to these functions will have already been validated. The last
Expand Down Expand Up @@ -204,21 +189,6 @@ class CONTENT_EXPORT PepperGraphics2DHost
bool texture_mailbox_modified_;
bool is_using_texture_layer_;

// The offset into the plugin area at which to draw the contents of the
// graphics context.
gfx::Point plugin_offset_;

// The size of the plugin element from the plugin's perspective at the last
// time Flush() was called. Because the plugin runs in a separate process and
// the size of the plugin element in the renderer is updated asynchronously,
// it may believe that the plugin element is a different size to what it
// actually is.
gfx::Size flushed_plugin_size_;
// The current size of the plugin element.
gfx::Size current_plugin_size_;

PP_Graphics2D_Dev_ResizeMode resize_mode_;

friend class PepperGraphics2DHostTest;
DISALLOW_COPY_AND_ASSIGN(PepperGraphics2DHost);
};
Expand Down
Loading

0 comments on commit bd51beb

Please sign in to comment.