summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 20:10:08 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-16 20:10:08 +0000
commit4ee95fa47309b036eb366f214616bf5409af2e87 (patch)
tree671bb973a8a37d07ad7bce2211f6e8ed10499bd2 /ppapi
parent3e4d21fb77ba92564a4f75e56433e517d8319ffa (diff)
downloadchromium_src-4ee95fa47309b036eb366f214616bf5409af2e87.zip
chromium_src-4ee95fa47309b036eb366f214616bf5409af2e87.tar.gz
chromium_src-4ee95fa47309b036eb366f214616bf5409af2e87.tar.bz2
Pepper: Add a wrapper for the private PPB_Flash interface.
Make it backwards-compatible and work with both the 11 and 12.0 interfaces. TEST=builds Review URL: http://codereview.chromium.org/8966027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/cpp/private/flash.cc177
-rw-r--r--ppapi/cpp/private/flash.h59
-rw-r--r--ppapi/ppapi_sources.gypi2
3 files changed, 238 insertions, 0 deletions
diff --git a/ppapi/cpp/private/flash.cc b/ppapi/cpp/private/flash.cc
new file mode 100644
index 0000000..bab400b
--- /dev/null
+++ b/ppapi/cpp/private/flash.cc
@@ -0,0 +1,177 @@
+// 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.
+
+#include "ppapi/cpp/private/flash.h"
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/dev/font_dev.h"
+#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/point.h"
+#include "ppapi/cpp/rect.h"
+#include "ppapi/cpp/url_request_info.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/c/private/ppb_flash.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_Flash>() {
+ return PPB_FLASH_INTERFACE;
+}
+
+template <> const char* interface_name<PPB_Flash_11>() {
+ return PPB_FLASH_INTERFACE_11_0;
+}
+
+} // namespace
+
+namespace flash {
+
+// static
+bool Flash::IsAvailable() {
+ return has_interface<PPB_Flash>() || has_interface<PPB_Flash_11>();
+}
+
+// static
+void Flash::SetInstanceAlwaysOnTop(Instance* instance, bool on_top) {
+ if (has_interface<PPB_Flash>()) {
+ get_interface<PPB_Flash>()->SetInstanceAlwaysOnTop(instance->pp_instance(),
+ PP_FromBool(on_top));
+ } else if (has_interface<PPB_Flash_11>()) {
+ get_interface<PPB_Flash_11>()->SetInstanceAlwaysOnTop(
+ instance->pp_instance(), PP_FromBool(on_top));
+ }
+}
+
+// static
+bool Flash::DrawGlyphs(Instance* instance,
+ ImageData* image,
+ const FontDescription_Dev& font_desc,
+ uint32_t color,
+ const Point& position,
+ const Rect& clip,
+ const float transformation[3][3],
+ bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]) {
+ bool rv = false;
+ if (has_interface<PPB_Flash>()) {
+ rv = PP_ToBool(get_interface<PPB_Flash>()->DrawGlyphs(
+ instance->pp_instance(),
+ image->pp_resource(),
+ &font_desc.pp_font_description(),
+ color,
+ &position.pp_point(),
+ &clip.pp_rect(),
+ transformation,
+ PP_FromBool(allow_subpixel_aa),
+ glyph_count,
+ glyph_indices,
+ glyph_advances));
+ } else if (has_interface<PPB_Flash_11>()) {
+ rv = PP_ToBool(get_interface<PPB_Flash_11>()->DrawGlyphs(
+ instance->pp_instance(),
+ image->pp_resource(),
+ &font_desc.pp_font_description(),
+ color,
+ position.pp_point(),
+ clip.pp_rect(),
+ transformation,
+ glyph_count,
+ glyph_indices,
+ glyph_advances));
+ }
+ return rv;
+}
+
+// static
+Var Flash::GetProxyForURL(Instance* instance, const std::string& url) {
+ Var rv;
+ if (has_interface<PPB_Flash>()) {
+ rv = Var(Var::PassRef(),
+ get_interface<PPB_Flash>()->GetProxyForURL(instance->pp_instance(),
+ url.c_str()));
+ } else if (has_interface<PPB_Flash_11>()) {
+ rv = Var(Var::PassRef(),
+ get_interface<PPB_Flash_11>()->GetProxyForURL(
+ instance->pp_instance(), url.c_str()));
+ }
+ return rv;
+}
+
+// static
+int32_t Flash::Navigate(const URLRequestInfo& request_info,
+ const std::string& target,
+ bool from_user_action) {
+ int32_t rv = PP_ERROR_FAILED;
+ if (has_interface<PPB_Flash>()) {
+ rv = get_interface<PPB_Flash>()->Navigate(request_info.pp_resource(),
+ target.c_str(),
+ PP_FromBool(from_user_action));
+ } else if (has_interface<PPB_Flash_11>()) {
+ rv = get_interface<PPB_Flash_11>()->Navigate(request_info.pp_resource(),
+ target.c_str(),
+ from_user_action);
+ }
+ return rv;
+}
+
+// static
+void Flash::RunMessageLoop(Instance* instance) {
+ if (has_interface<PPB_Flash>())
+ get_interface<PPB_Flash>()->RunMessageLoop(instance->pp_instance());
+ else if (has_interface<PPB_Flash_11>())
+ get_interface<PPB_Flash_11>()->RunMessageLoop(instance->pp_instance());
+}
+
+// static
+void Flash::QuitMessageLoop(Instance* instance) {
+ if (has_interface<PPB_Flash>())
+ get_interface<PPB_Flash>()->QuitMessageLoop(instance->pp_instance());
+ else if (has_interface<PPB_Flash_11>())
+ get_interface<PPB_Flash_11>()->QuitMessageLoop(instance->pp_instance());
+}
+
+// static
+double Flash::GetLocalTimeZoneOffset(Instance* instance, PP_Time t) {
+ double rv = 0;
+ if (has_interface<PPB_Flash>()) {
+ rv = get_interface<PPB_Flash>()->GetLocalTimeZoneOffset(
+ instance->pp_instance(), t);
+ } else if (has_interface<PPB_Flash_11>()) {
+ rv = get_interface<PPB_Flash_11>()->GetLocalTimeZoneOffset(
+ instance->pp_instance(), t);
+ }
+ return rv;
+}
+
+// static
+Var Flash::GetCommandLineArgs(Module* module) {
+ Var rv;
+ if (has_interface<PPB_Flash>()) {
+ rv = Var(Var::PassRef(),
+ get_interface<PPB_Flash>()->GetCommandLineArgs(
+ module->pp_module()));
+ } else if (has_interface<PPB_Flash_11>()) {
+ rv = Var(Var::PassRef(),
+ get_interface<PPB_Flash_11>()->GetCommandLineArgs(
+ module->pp_module()));
+ }
+ return rv;
+}
+
+// static
+void Flash::PreloadFontWin(const void* logfontw) {
+ if (has_interface<PPB_Flash>())
+ get_interface<PPB_Flash>()->PreloadFontWin(logfontw);
+}
+
+} // namespace flash
+} // namespace pp
diff --git a/ppapi/cpp/private/flash.h b/ppapi/cpp/private/flash.h
new file mode 100644
index 0000000..e47bff0
--- /dev/null
+++ b/ppapi/cpp/private/flash.h
@@ -0,0 +1,59 @@
+// 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 PPAPI_CPP_PRIVATE_FLASH_H_
+#define PPAPI_CPP_PRIVATE_FLASH_H_
+
+#include <string>
+
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/pp_time.h"
+
+struct PP_Point;
+
+namespace pp {
+
+class FontDescription_Dev;
+class ImageData;
+class Instance;
+class Module;
+class Point;
+class Rect;
+class URLRequestInfo;
+class Var;
+
+namespace flash {
+
+class Flash {
+ public:
+ // Returns true if the required interface is available.
+ static bool IsAvailable();
+
+ static void SetInstanceAlwaysOnTop(Instance* instance, bool on_top);
+ static bool DrawGlyphs(Instance* instance,
+ ImageData* image,
+ const FontDescription_Dev& font_desc,
+ uint32_t color,
+ const Point& position,
+ const Rect& clip,
+ const float transformation[3][3],
+ bool allow_subpixel_aa,
+ uint32_t glyph_count,
+ const uint16_t glyph_indices[],
+ const PP_Point glyph_advances[]);
+ static Var GetProxyForURL(Instance* instance, const std::string& url);
+ static int32_t Navigate(const URLRequestInfo& request_info,
+ const std::string& target,
+ bool from_user_action);
+ static void RunMessageLoop(Instance* instance);
+ static void QuitMessageLoop(Instance* instance);
+ static double GetLocalTimeZoneOffset(Instance* instance, PP_Time t);
+ static Var GetCommandLineArgs(Module* module);
+ static void PreloadFontWin(const void* logfontw);
+};
+
+} // namespace flash
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_FLASH_H_
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 00323d6..49e74fd 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -225,6 +225,8 @@
'cpp/dev/scriptable_object_deprecated.cc',
# Private interfaces.
+ 'cpp/private/flash.cc',
+ 'cpp/private/flash.h',
'cpp/private/flash_fullscreen.cc',
'cpp/private/flash_fullscreen.h',
'cpp/private/flash_menu.cc',