summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorjhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 19:33:33 +0000
committerjhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 19:33:33 +0000
commit0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a (patch)
tree4f52f8e8297c613550899b6685dcba9718f103c8 /ppapi/proxy
parent65828ab68c586b3074e8705644f7d93b54bac418 (diff)
downloadchromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.zip
chromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.tar.gz
chromium_src-0cd5b9dfd0882bcb8ecf70a4b135e8d79113d28a.tar.bz2
Implement HiDPI support in Pepper dev interface
This patch requires WebKit patch https://bugs.webkit.org/show_bug.cgi?id=87874 (WebKit r121364) Expose device_scale_factor and css_scale_factor to Pepper plugins via a dev interface on View resource. Allow Pepper plugins to create a 2D graphics context with a scale factor so the plugins can render at device resolution rather than DIPs if they want. BUG=114673 TEST=browser_tests --gtest_filter="PPAPITest.*" TEST=browser_tests --gtest_filter="OutOfProcessPPAPITest.*" TEST=Build, run existing PPAPI plugin at 2x scale TEST=Build, run test HiDPI aware plugin to render at device rez, at 1x, 2x scale Review URL: https://chromiumcodereview.appspot.com/10544168 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144773 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/interface_list.cc2
-rw-r--r--ppapi/proxy/ppapi_messages.h5
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.cc29
-rw-r--r--ppapi/proxy/ppb_graphics_2d_proxy.h2
4 files changed, 37 insertions, 1 deletions
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index f801276..ffed09f 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -15,6 +15,7 @@
#include "ppapi/c/dev/ppb_font_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_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_keyboard_input_event_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
@@ -27,6 +28,7 @@
#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppb_video_capture_dev.h"
+#include "ppapi/c/dev/ppb_view_dev.h"
#include "ppapi/c/ppb_audio_config.h"
#include "ppapi/c/ppb_audio.h"
#include "ppapi/c/ppb_core.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 69005e5..755d353 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -144,6 +144,8 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::ViewData)
IPC_STRUCT_TRAITS_MEMBER(is_fullscreen)
IPC_STRUCT_TRAITS_MEMBER(is_page_visible)
IPC_STRUCT_TRAITS_MEMBER(clip_rect)
+ IPC_STRUCT_TRAITS_MEMBER(device_scale)
+ IPC_STRUCT_TRAITS_MEMBER(css_scale)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(PP_TouchPoint)
@@ -858,6 +860,9 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBGraphics2D_ReplaceContents,
ppapi::HostResource /* image_data */)
IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBGraphics2D_Flush,
ppapi::HostResource /* graphics_2d */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBGraphics2D_Dev_SetScale,
+ ppapi::HostResource /* graphics_2d */,
+ float /* scale */)
#if !defined(OS_NACL)
// PPB_Graphics3D.
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.cc b/ppapi/proxy/ppb_graphics_2d_proxy.cc
index 2fc34cc..909abc1 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.cc
@@ -43,6 +43,8 @@ class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API {
void Scroll(const PP_Rect* clip_rect,
const PP_Point* amount);
void ReplaceContents(PP_Resource image_data);
+ bool SetScale(float scale);
+ float GetScale();
int32_t Flush(scoped_refptr<TrackedCallback> callback);
// Notification that the host has sent an ACK for a pending Flush.
@@ -57,6 +59,7 @@ class Graphics2D : public Resource, public thunk::PPB_Graphics2D_API {
PP_Size size_;
PP_Bool is_always_opaque_;
+ float scale_;
// In the plugin, this is the current callback set for Flushes. When the
// pointer is non-NULL, we're waiting for a flush ACK.
@@ -70,7 +73,8 @@ Graphics2D::Graphics2D(const HostResource& host_resource,
PP_Bool is_always_opaque)
: Resource(OBJECT_IS_PROXY, host_resource),
size_(size),
- is_always_opaque_(is_always_opaque) {
+ is_always_opaque_(is_always_opaque),
+ scale_(1.0f) {
}
Graphics2D::~Graphics2D() {
@@ -126,6 +130,19 @@ void Graphics2D::ReplaceContents(PP_Resource image_data) {
kApiID, host_resource(), image_object->host_resource()));
}
+bool Graphics2D::SetScale(float scale) {
+ if (scale <= 0.0f)
+ return false;
+ GetDispatcher()->Send(new PpapiHostMsg_PPBGraphics2D_Dev_SetScale(
+ kApiID, host_resource(), scale));
+ scale_ = scale;
+ return true;
+}
+
+float Graphics2D::GetScale() {
+ return scale_;
+}
+
int32_t Graphics2D::Flush(scoped_refptr<TrackedCallback> callback) {
if (TrackedCallback::IsPending(current_flush_callback_))
return PP_ERROR_INPROGRESS; // Can't have >1 flush pending.
@@ -178,6 +195,8 @@ bool PPB_Graphics2D_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnHostMsgReplaceContents)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Flush,
OnHostMsgFlush)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics2D_Dev_SetScale,
+ OnHostMsgSetScale)
IPC_MESSAGE_HANDLER(PpapiMsg_PPBGraphics2D_FlushACK,
OnPluginMsgFlushACK)
@@ -239,6 +258,14 @@ void PPB_Graphics2D_Proxy::OnHostMsgFlush(const HostResource& graphics_2d) {
enter.SetResult(enter.object()->Flush(enter.callback()));
}
+void PPB_Graphics2D_Proxy::OnHostMsgSetScale(const HostResource& graphics_2d,
+ float scale) {
+ EnterHostFromHostResource<PPB_Graphics2D_API> enter(graphics_2d);
+ if (enter.failed())
+ return;
+ enter.object()->SetScale(scale);
+}
+
void PPB_Graphics2D_Proxy::OnPluginMsgFlushACK(
const HostResource& host_resource,
int32_t pp_error) {
diff --git a/ppapi/proxy/ppb_graphics_2d_proxy.h b/ppapi/proxy/ppb_graphics_2d_proxy.h
index f7afb64..45043ce 100644
--- a/ppapi/proxy/ppb_graphics_2d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_2d_proxy.h
@@ -55,6 +55,8 @@ class PPB_Graphics2D_Proxy : public InterfaceProxy {
void OnHostMsgReplaceContents(const HostResource& graphics_2d,
const HostResource& image_data);
void OnHostMsgFlush(const HostResource& graphics_2d);
+ void OnHostMsgSetScale(const HostResource& graphics_2d,
+ float scale);
// Host->plugin message handlers.
void OnPluginMsgFlushACK(const HostResource& graphics_2d,