0

Added SetLayerTransform to PPAPI.

SetLayerTransform() sets a transformation factor that will be applied for the current
layer displayed on the output device.
This function has no effect until you call Flush().
@param[in] scale The scale to be applied.
@param[in] origin The origin of the scale.
@param[in] translate The translation to be applied.

@return Returns true on success or false if the resource is invalid or the scale factor is 0 or less.

BUG=605379
NOPRESUBMIT=true

Reason:
** Presubmit ERRORS **
TODOs found in stable public PPAPI files:
ppapi/cpp/graphics_2d.h

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

Cr-Commit-Position: refs/heads/master@{#388851}
This commit is contained in:
alessandroa
2016-04-21 12:35:25 -07:00
committed by Commit bot
parent f4b5752dbe
commit d55efd0d4b
19 changed files with 286 additions and 16 deletions

@ -130,7 +130,7 @@ void ConvertImageData(PPB_ImageData_Impl* src_image,
} // namespace
struct PepperGraphics2DHost::QueuedOperation {
enum Type { PAINT, SCROLL, REPLACE, };
enum Type { PAINT, SCROLL, REPLACE, TRANSFORM };
QueuedOperation(Type t)
: type(t), paint_x(0), paint_y(0), scroll_dx(0), scroll_dy(0) {}
@ -148,6 +148,10 @@ struct PepperGraphics2DHost::QueuedOperation {
// Valid when type == REPLACE.
scoped_refptr<PPB_ImageData_Impl> replace_image;
// Valid when type == TRANSFORM
float scale;
gfx::PointF translation;
};
// static
@ -223,6 +227,8 @@ int32_t PepperGraphics2DHost::OnResourceMessageReceived(
OnHostMsgFlush)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetScale,
OnHostMsgSetScale)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_SetLayerTransform,
OnHostMsgSetLayerTransform)
PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Graphics2D_ReadImageData,
OnHostMsgReadImageData)
PPAPI_END_MESSAGE_MAP()
@ -524,6 +530,21 @@ int32_t PepperGraphics2DHost::OnHostMsgSetScale(
return PP_ERROR_BADARGUMENT;
}
int32_t PepperGraphics2DHost::OnHostMsgSetLayerTransform(
ppapi::host::HostMessageContext* context,
float scale,
const PP_FloatPoint& translation) {
if (scale < 0.0f)
return PP_ERROR_BADARGUMENT;
QueuedOperation operation(QueuedOperation::TRANSFORM);
operation.scale = scale;
operation.translation = gfx::PointF(translation.x, translation.y);
queued_operations_.push_back(operation);
return PP_OK;
}
int32_t PepperGraphics2DHost::OnHostMsgReadImageData(
ppapi::host::HostMessageContext* context,
PP_Resource image,
@ -590,10 +611,15 @@ 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;
switch (operation.type) {
case QueuedOperation::TRANSFORM:
ExecuteTransform(operation.scale, operation.translation);
no_update_visible = false;
break;
case QueuedOperation::PAINT:
ExecutePaintImageData(operation.paint_image.get(),
operation.paint_x,
@ -679,6 +705,11 @@ int32_t PepperGraphics2DHost::Flush(PP_Resource* old_image_data) {
return PP_OK_COMPLETIONPENDING;
}
void PepperGraphics2DHost::ExecuteTransform(const float& scale,
const gfx::PointF& translate) {
bound_instance_->SetGraphics2DTransform(scale, translate);
}
void PepperGraphics2DHost::ExecutePaintImageData(PPB_ImageData_Impl* image,
int x,
int y,

@ -18,6 +18,7 @@
#include "ppapi/host/resource_host.h"
#include "third_party/WebKit/public/platform/WebCanvas.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
namespace cc {
@ -86,6 +87,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
void SetScale(float scale);
float GetScale() const;
void SetLayerTransform(float scale, const PP_Point& transform);
bool IsAlwaysOpaque() const;
PPB_ImageData_Impl* ImageData();
gfx::Size Size() const;
@ -116,6 +118,9 @@ class CONTENT_EXPORT PepperGraphics2DHost
int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
int32_t OnHostMsgSetScale(ppapi::host::HostMessageContext* context,
float scale);
int32_t OnHostMsgSetLayerTransform(ppapi::host::HostMessageContext* context,
float Scale,
const PP_FloatPoint& Transform);
int32_t OnHostMsgReadImageData(ppapi::host::HostMessageContext* context,
PP_Resource image,
const PP_Point& top_left);
@ -129,6 +134,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
// rect argument will be filled by each function with the area affected by
// the update that requires invalidation. If there were no pixels changed,
// this rect can be untouched.
void ExecuteTransform(const float& scale, const gfx::PointF& translate);
void ExecutePaintImageData(PPB_ImageData_Impl* image,
int x,
int y,

@ -479,6 +479,8 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
module_(module),
instance_interface_(instance_interface),
pp_instance_(0),
graphics2d_translation_(0, 0),
graphics2d_scale_(1.f),
container_(container),
layer_bound_to_fullscreen_(false),
layer_is_hardware_(false),
@ -1544,6 +1546,15 @@ bool PepperPluginInstanceImpl::LoadTextInputInterface() {
return !!plugin_textinput_interface_;
}
void PepperPluginInstanceImpl::SetGraphics2DTransform(
const float& scale,
const gfx::PointF& translation) {
graphics2d_scale_ = scale;
graphics2d_translation_ = translation;
UpdateLayerTransform();
}
void PepperPluginInstanceImpl::UpdateLayerTransform() {
if (!bound_graphics_2d_platform_ || !texture_layer_) {
// Currently the transform is only applied for Graphics2D.
@ -1563,11 +1574,24 @@ void PepperPluginInstanceImpl::UpdateLayerTransform() {
gfx::Size plugin_size_in_dip(view_data_.rect.size.width,
view_data_.rect.size.height);
// Adding the SetLayerTransform from Graphics2D to the UV.
// If graphics2d_scale_ is 1.f and graphics2d_translation_ is 0 then UV will
// be top_left (0,0) and lower_right (plugin_size_in_dip.width() /
// graphics_2d_size_in_dip.width(), plugin_size_in_dip.height() /
// graphics_2d_size_in_dip.height())
gfx::PointF top_left =
gfx::PointF(-graphics2d_translation_.x() / graphics2d_scale_,
-graphics2d_translation_.y() / graphics2d_scale_);
gfx::PointF lower_right =
gfx::PointF((1 / graphics2d_scale_) * plugin_size_in_dip.width() -
graphics2d_translation_.x() / graphics2d_scale_,
(1 / graphics2d_scale_) * plugin_size_in_dip.height() -
graphics2d_translation_.y() / graphics2d_scale_);
texture_layer_->SetUV(
gfx::PointF(0.0f, 0.0f),
gfx::PointF(
plugin_size_in_dip.width() / graphics_2d_size_in_dip.width(),
plugin_size_in_dip.height() / graphics_2d_size_in_dip.height()));
gfx::PointF(top_left.x() / graphics_2d_size_in_dip.width(),
top_left.y() / graphics_2d_size_in_dip.height()),
gfx::PointF(lower_right.x() / graphics_2d_size_in_dip.width(),
lower_right.y() / graphics_2d_size_in_dip.height()));
}
bool PepperPluginInstanceImpl::PluginHasFocus() const {

@ -372,6 +372,9 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
ContentDecryptorDelegate* GetContentDecryptorDelegate();
void SetGraphics2DTransform(const float& scale,
const gfx::PointF& translation);
// PluginInstance implementation
RenderView* GetRenderView() override;
blink::WebPluginContainer* GetContainer() override;
@ -711,6 +714,10 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
PP_Instance pp_instance_;
// These are the scale and the translation that will be applied to the layer.
gfx::PointF graphics2d_translation_;
float graphics2d_scale_;
// NULL until we have been initialized.
blink::WebPluginContainer* container_;
scoped_refptr<cc::Layer> compositor_layer_;

@ -12,7 +12,8 @@
label Chrome {
M14 = 1.0,
M27 = 1.1
M27 = 1.1,
M52 = 1.2
};
/**
@ -282,5 +283,26 @@ interface PPB_Graphics2D {
float_t GetScale(
[in] PP_Resource resource);
/**
* SetLayerTransform() sets a transformation factor that will be applied for
* the current graphics context displayed on the output device. If both
* SetScale and SetLayerTransform will be used, they are going to get combined
* for the final result.
*
* This function has no effect until you call Flush().
*
* @param[in] scale The scale to be applied.
* @param[in] origin The origin of the scale.
* @param[in] translate The translation to be applied.
*
* @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code>
* if the resource is invalid or the scale factor is 0 or less.
*/
[version=1.2]
PP_Bool SetLayerTransform(
[in] PP_Resource resource,
[in] float_t scale,
[in] PP_Point origin,
[in] PP_Point translate);
};

@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
/* From pp_macros.idl modified Fri Jun 13 10:40:42 2014. */
/* From pp_macros.idl modified Mon Feb 1 13:37:12 2016. */
#ifndef PPAPI_C_PP_MACROS_H_
#define PPAPI_C_PP_MACROS_H_
#define PPAPI_RELEASE 48
#define PPAPI_RELEASE 52
/**
* @file

@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From ppb_graphics_2d.idl modified Fri Apr 26 08:49:08 2013. */
/* From ppb_graphics_2d.idl modified Wed Apr 20 13:37:06 2016. */
#ifndef PPAPI_C_PPB_GRAPHICS_2D_H_
#define PPAPI_C_PPB_GRAPHICS_2D_H_
@ -20,7 +20,8 @@
#define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0"
#define PPB_GRAPHICS_2D_INTERFACE_1_1 "PPB_Graphics2D;1.1"
#define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_1
#define PPB_GRAPHICS_2D_INTERFACE_1_2 "PPB_Graphics2D;1.2"
#define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_2
/**
* @file
@ -36,7 +37,7 @@
/**
* <code>PPB_Graphics2D</code> defines the interface for a 2D graphics context.
*/
struct PPB_Graphics2D_1_1 {
struct PPB_Graphics2D_1_2 {
/**
* Create() creates a 2D graphics context. The returned graphics context will
* not be bound to the module instance on creation (call BindGraphics() on
@ -276,9 +277,28 @@ struct PPB_Graphics2D_1_1 {
* is not a valid <code>Graphics2D</code> context, this will return 0.0.
*/
float (*GetScale)(PP_Resource resource);
/**
* SetLayerTransform() sets a transformation factor that will be applied for
* the current graphics context displayed on the output device. If both
* SetScale and SetLayerTransform will be used, they are going to get combined
* for the final result.
*
* This function has no effect until you call Flush().
*
* @param[in] scale The scale to be applied.
* @param[in] origin The origin of the scale.
* @param[in] translate The translation to be applied.
*
* @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code>
* if the resource is invalid or the scale factor is 0 or less.
*/
PP_Bool (*SetLayerTransform)(PP_Resource resource,
float scale,
const struct PP_Point* origin,
const struct PP_Point* translate);
};
typedef struct PPB_Graphics2D_1_1 PPB_Graphics2D;
typedef struct PPB_Graphics2D_1_2 PPB_Graphics2D;
struct PPB_Graphics2D_1_0 {
PP_Resource (*Create)(PP_Instance instance,
@ -299,6 +319,28 @@ struct PPB_Graphics2D_1_0 {
int32_t (*Flush)(PP_Resource graphics_2d,
struct PP_CompletionCallback callback);
};
struct PPB_Graphics2D_1_1 {
PP_Resource (*Create)(PP_Instance instance,
const struct PP_Size* size,
PP_Bool is_always_opaque);
PP_Bool (*IsGraphics2D)(PP_Resource resource);
PP_Bool (*Describe)(PP_Resource graphics_2d,
struct PP_Size* size,
PP_Bool* is_always_opaque);
void (*PaintImageData)(PP_Resource graphics_2d,
PP_Resource image_data,
const struct PP_Point* top_left,
const struct PP_Rect* src_rect);
void (*Scroll)(PP_Resource graphics_2d,
const struct PP_Rect* clip_rect,
const struct PP_Point* amount);
void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data);
int32_t (*Flush)(PP_Resource graphics_2d,
struct PP_CompletionCallback callback);
PP_Bool (*SetScale)(PP_Resource resource, float scale);
float (*GetScale)(PP_Resource resource);
};
/**
* @}
*/

@ -26,6 +26,11 @@ template <> const char* interface_name<PPB_Graphics2D_1_1>() {
return PPB_GRAPHICS_2D_INTERFACE_1_1;
}
template <> const char* interface_name<PPB_Graphics2D_1_2>() {
return PPB_GRAPHICS_2D_INTERFACE_1_2;
}
} // namespace
Graphics2D::Graphics2D() : Resource() {
@ -152,4 +157,14 @@ float Graphics2D::GetScale() {
return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource());
}
bool Graphics2D::SetLayerTransform(float scale,
const Point& origin,
const Point& translate) {
if (!has_interface<PPB_Graphics2D_1_2>())
return false;
return PP_ToBool(get_interface<PPB_Graphics2D_1_2>()->SetLayerTransform(
pp_resource(), scale, &origin.pp_point(), &translate.pp_point()));
}
} // namespace pp

@ -284,6 +284,9 @@ class Graphics2D : public Resource {
/// is 1.0.
float GetScale();
bool SetLayerTransform(float scale,
const Point& origin,
const Point& translate);
private:
Size size_;
};

@ -107,6 +107,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileRef_1_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileSystem_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_2;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics3D_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_HostResolver_1_0;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_MouseInputEvent_1_0;
@ -871,6 +872,60 @@ static float Pnacl_M27_PPB_Graphics2D_GetScale(PP_Resource resource) {
/* End wrapper methods for PPB_Graphics2D_1_1 */
/* Begin wrapper methods for PPB_Graphics2D_1_2 */
static PP_Resource Pnacl_M52_PPB_Graphics2D_Create(PP_Instance instance, const struct PP_Size* size, PP_Bool is_always_opaque) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->Create(instance, size, is_always_opaque);
}
static PP_Bool Pnacl_M52_PPB_Graphics2D_IsGraphics2D(PP_Resource resource) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->IsGraphics2D(resource);
}
static PP_Bool Pnacl_M52_PPB_Graphics2D_Describe(PP_Resource graphics_2d, struct PP_Size* size, PP_Bool* is_always_opaque) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->Describe(graphics_2d, size, is_always_opaque);
}
static void Pnacl_M52_PPB_Graphics2D_PaintImageData(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point* top_left, const struct PP_Rect* src_rect) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
iface->PaintImageData(graphics_2d, image_data, top_left, src_rect);
}
static void Pnacl_M52_PPB_Graphics2D_Scroll(PP_Resource graphics_2d, const struct PP_Rect* clip_rect, const struct PP_Point* amount) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
iface->Scroll(graphics_2d, clip_rect, amount);
}
static void Pnacl_M52_PPB_Graphics2D_ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
iface->ReplaceContents(graphics_2d, image_data);
}
static int32_t Pnacl_M52_PPB_Graphics2D_Flush(PP_Resource graphics_2d, struct PP_CompletionCallback* callback) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->Flush(graphics_2d, *callback);
}
static PP_Bool Pnacl_M52_PPB_Graphics2D_SetScale(PP_Resource resource, float scale) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->SetScale(resource, scale);
}
static float Pnacl_M52_PPB_Graphics2D_GetScale(PP_Resource resource) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->GetScale(resource);
}
static PP_Bool Pnacl_M52_PPB_Graphics2D_SetLayerTransform(PP_Resource resource, float scale, const struct PP_Point* origin, const struct PP_Point* translate) {
const struct PPB_Graphics2D_1_2 *iface = Pnacl_WrapperInfo_PPB_Graphics2D_1_2.real_iface;
return iface->SetLayerTransform(resource, scale, origin, translate);
}
/* End wrapper methods for PPB_Graphics2D_1_2 */
/* Begin wrapper methods for PPB_Graphics3D_1_0 */
static int32_t Pnacl_M15_PPB_Graphics3D_GetAttribMaxValue(PP_Resource instance, int32_t attribute, int32_t* value) {
@ -4795,6 +4850,19 @@ static const struct PPB_Graphics2D_1_1 Pnacl_Wrappers_PPB_Graphics2D_1_1 = {
.GetScale = (float (*)(PP_Resource resource))&Pnacl_M27_PPB_Graphics2D_GetScale
};
static const struct PPB_Graphics2D_1_2 Pnacl_Wrappers_PPB_Graphics2D_1_2 = {
.Create = (PP_Resource (*)(PP_Instance instance, const struct PP_Size* size, PP_Bool is_always_opaque))&Pnacl_M52_PPB_Graphics2D_Create,
.IsGraphics2D = (PP_Bool (*)(PP_Resource resource))&Pnacl_M52_PPB_Graphics2D_IsGraphics2D,
.Describe = (PP_Bool (*)(PP_Resource graphics_2d, struct PP_Size* size, PP_Bool* is_always_opaque))&Pnacl_M52_PPB_Graphics2D_Describe,
.PaintImageData = (void (*)(PP_Resource graphics_2d, PP_Resource image_data, const struct PP_Point* top_left, const struct PP_Rect* src_rect))&Pnacl_M52_PPB_Graphics2D_PaintImageData,
.Scroll = (void (*)(PP_Resource graphics_2d, const struct PP_Rect* clip_rect, const struct PP_Point* amount))&Pnacl_M52_PPB_Graphics2D_Scroll,
.ReplaceContents = (void (*)(PP_Resource graphics_2d, PP_Resource image_data))&Pnacl_M52_PPB_Graphics2D_ReplaceContents,
.Flush = (int32_t (*)(PP_Resource graphics_2d, struct PP_CompletionCallback callback))&Pnacl_M52_PPB_Graphics2D_Flush,
.SetScale = (PP_Bool (*)(PP_Resource resource, float scale))&Pnacl_M52_PPB_Graphics2D_SetScale,
.GetScale = (float (*)(PP_Resource resource))&Pnacl_M52_PPB_Graphics2D_GetScale,
.SetLayerTransform = (PP_Bool (*)(PP_Resource resource, float scale, const struct PP_Point* origin, const struct PP_Point* translate))&Pnacl_M52_PPB_Graphics2D_SetLayerTransform
};
static const struct PPB_Graphics3D_1_0 Pnacl_Wrappers_PPB_Graphics3D_1_0 = {
.GetAttribMaxValue = (int32_t (*)(PP_Resource instance, int32_t attribute, int32_t* value))&Pnacl_M15_PPB_Graphics3D_GetAttribMaxValue,
.Create = (PP_Resource (*)(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]))&Pnacl_M15_PPB_Graphics3D_Create,
@ -5927,6 +5995,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_1 = {
.real_iface = NULL
};
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics2D_1_2 = {
.iface_macro = PPB_GRAPHICS_2D_INTERFACE_1_2,
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Graphics2D_1_2,
.real_iface = NULL
};
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Graphics3D_1_0 = {
.iface_macro = PPB_GRAPHICS_3D_INTERFACE_1_0,
.wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_Graphics3D_1_0,
@ -6524,6 +6598,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_FileSystem_1_0,
&Pnacl_WrapperInfo_PPB_Graphics2D_1_0,
&Pnacl_WrapperInfo_PPB_Graphics2D_1_1,
&Pnacl_WrapperInfo_PPB_Graphics2D_1_2,
&Pnacl_WrapperInfo_PPB_Graphics3D_1_0,
&Pnacl_WrapperInfo_PPB_HostResolver_1_0,
&Pnacl_WrapperInfo_PPB_MouseInputEvent_1_0,

@ -113,6 +113,20 @@ float Graphics2DResource::GetScale() {
return scale_;
}
PP_Bool Graphics2DResource::SetLayerTransform(float scale,
const PP_Point* origin,
const PP_Point* translate) {
if (scale <= 0.0f)
return PP_FALSE;
// Adding the origin to the transform.
PP_FloatPoint translate_with_origin;
translate_with_origin.x = (1 - scale) * origin->x - translate->x;
translate_with_origin.y = (1 - scale) * origin->y - translate->y;
Post(RENDERER,
PpapiHostMsg_Graphics2D_SetLayerTransform(scale, translate_with_origin));
return PP_TRUE;
}
int32_t Graphics2DResource::Flush(scoped_refptr<TrackedCallback> callback) {
// If host is not even created, return failure immediately. This can happen
// when failed to initialize (in constructor).

@ -42,6 +42,9 @@ class PPAPI_PROXY_EXPORT Graphics2DResource
void ReplaceContents(PP_Resource image_data) override;
PP_Bool SetScale(float scale) override;
float GetScale() override;
PP_Bool SetLayerTransform(float scale,
const PP_Point* origin,
const PP_Point* translate) override;
int32_t Flush(scoped_refptr<TrackedCallback> callback) override;
bool ReadImageData(PP_Resource image, const PP_Point* top_left) override;

@ -1655,6 +1655,9 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_Graphics2D_ReplaceContents,
ppapi::HostResource /* image_data */)
IPC_MESSAGE_CONTROL1(PpapiHostMsg_Graphics2D_SetScale,
float /* scale */)
IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_SetLayerTransform,
float /* scale */,
PP_FloatPoint /* translate */)
// Graphics2D, plugin -> host -> plugin
IPC_MESSAGE_CONTROL0(PpapiHostMsg_Graphics2D_Flush)

@ -32,7 +32,7 @@ bool CanFlushContext(pp::Instance* instance, pp::Graphics2D* context) {
}
bool CanFlushContextC(pp::Instance* instance, PP_Resource graphics_2d,
const PPB_Graphics2D_1_1* graphics_2d_if) {
const PPB_Graphics2D_1_2* graphics_2d_if) {
TestCompletionCallback callback(instance->pp_instance());
callback.WaitForResult(graphics_2d_if->Flush(
graphics_2d, callback.GetCallback().pp_completion_callback()));
@ -49,7 +49,7 @@ TestGraphics2D::TestGraphics2D(TestingInstance* instance)
bool TestGraphics2D::Init() {
graphics_2d_interface_ = static_cast<const PPB_Graphics2D*>(
pp::Module::Get()->GetBrowserInterface(PPB_GRAPHICS_2D_INTERFACE_1_1));
pp::Module::Get()->GetBrowserInterface(PPB_GRAPHICS_2D_INTERFACE_1_2));
image_data_interface_ = static_cast<const PPB_ImageData*>(
pp::Module::Get()->GetBrowserInterface(PPB_IMAGEDATA_INTERFACE_1_0));
return graphics_2d_interface_ && image_data_interface_ &&

@ -104,7 +104,7 @@ class TestGraphics2D : public TestCase {
std::string TestBindNull();
// Used by the tests that access the C API directly.
const PPB_Graphics2D_1_1* graphics_2d_interface_;
const PPB_Graphics2D_1_2* graphics_2d_interface_;
const PPB_ImageData_1_0* image_data_interface_;
// Used to indicate that DidChangeView has happened, in order to make plugin

@ -60,6 +60,7 @@ PROXIED_IFACE(PPB_FILEIO_INTERFACE_1_0, PPB_FileIO_1_0)
PROXIED_IFACE(PPB_FILEIO_INTERFACE_1_1, PPB_FileIO_1_1)
PROXIED_IFACE(PPB_GRAPHICS_2D_INTERFACE_1_0, PPB_Graphics2D_1_0)
PROXIED_IFACE(PPB_GRAPHICS_2D_INTERFACE_1_1, PPB_Graphics2D_1_1)
PROXIED_IFACE(PPB_GRAPHICS_2D_INTERFACE_1_2, PPB_Graphics2D_1_2)
PROXIED_IFACE(PPB_HOSTRESOLVER_INTERFACE_1_0, PPB_HostResolver_1_0)
PROXIED_IFACE(PPB_IME_INPUT_EVENT_INTERFACE_1_0, PPB_IMEInputEvent_1_0)
PROXIED_IFACE(PPB_INPUT_EVENT_INTERFACE_1_0, PPB_InputEvent_1_0)

@ -36,6 +36,9 @@ class PPAPI_THUNK_EXPORT PPB_Graphics2D_API {
virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) = 0;
virtual PP_Bool SetScale(float scale) = 0;
virtual float GetScale() = 0;
virtual PP_Bool SetLayerTransform(float scale,
const PP_Point* origin,
const PP_Point* translate) = 0;
// Test only
virtual bool ReadImageData(PP_Resource image, const PP_Point* top_left) = 0;

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// From ppb_graphics_2d.idl modified Wed Jan 27 17:10:16 2016.
// From ppb_graphics_2d.idl modified Fri Apr 15 15:37:20 2016.
#include <stdint.h>
#include <string.h>
@ -102,6 +102,17 @@ float GetScale(PP_Resource resource) {
return enter.object()->GetScale();
}
PP_Bool SetLayerTransform(PP_Resource resource,
float scale,
const struct PP_Point* origin,
const struct PP_Point* translate) {
VLOG(4) << "PPB_Graphics2D::SetLayerTransform()";
EnterResource<PPB_Graphics2D_API> enter(resource, true);
if (enter.failed())
return PP_FALSE;
return enter.object()->SetLayerTransform(scale, origin, translate);
}
const PPB_Graphics2D_1_0 g_ppb_graphics2d_thunk_1_0 = {
&Create, &IsGraphics2D, &Describe, &PaintImageData,
&Scroll, &ReplaceContents, &Flush};
@ -110,6 +121,11 @@ const PPB_Graphics2D_1_1 g_ppb_graphics2d_thunk_1_1 = {
&Create, &IsGraphics2D, &Describe, &PaintImageData, &Scroll,
&ReplaceContents, &Flush, &SetScale, &GetScale};
const PPB_Graphics2D_1_2 g_ppb_graphics2d_thunk_1_2 = {
&Create, &IsGraphics2D, &Describe, &PaintImageData,
&Scroll, &ReplaceContents, &Flush, &SetScale,
&GetScale, &SetLayerTransform};
} // namespace
PPAPI_THUNK_EXPORT const PPB_Graphics2D_1_0* GetPPB_Graphics2D_1_0_Thunk() {
@ -120,5 +136,9 @@ PPAPI_THUNK_EXPORT const PPB_Graphics2D_1_1* GetPPB_Graphics2D_1_1_Thunk() {
return &g_ppb_graphics2d_thunk_1_1;
}
PPAPI_THUNK_EXPORT const PPB_Graphics2D_1_2* GetPPB_Graphics2D_1_2_Thunk() {
return &g_ppb_graphics2d_thunk_1_2;
}
} // namespace thunk
} // namespace ppapi

@ -80020,6 +80020,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="125017713" label="PPB_CameraCapabilities_Private;0.1"/>
<int value="126651696" label="PPB_ContentDecryptor_Private;0.12"/>
<int value="138418890" label="PPB_Memory(Dev);0.1"/>
<int value="150724524" label="PPB_Graphics2D;1.2"/>
<int value="153443470" label="PPB_URLResponseInfo;1.0"/>
<int value="153532707" label="PPB_Buffer(Dev);0.4"/>
<int value="156766028" label="PPB_UMA_Private;0.3"/>