summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authoryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 19:55:45 +0000
committeryzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-23 19:55:45 +0000
commit030ea0b2e4c7a596c30ffa3825eaac83807b33aa (patch)
tree3c384600881abf47a1b1609f2b164ef86b80ac17 /ppapi
parent6308cb72d0eebb3174c77161bdd8d5719c7f8978 (diff)
downloadchromium_src-030ea0b2e4c7a596c30ffa3825eaac83807b33aa.zip
chromium_src-030ea0b2e4c7a596c30ffa3825eaac83807b33aa.tar.gz
chromium_src-030ea0b2e4c7a596c30ffa3825eaac83807b33aa.tar.bz2
PPB_CursorControl_Dev.SetCursor: Add support for custom cursor.
BUG=none TEST=none Review URL: http://codereview.chromium.org/6720001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/example/example.cc33
1 files changed, 31 insertions, 2 deletions
diff --git a/ppapi/example/example.cc b/ppapi/example/example.cc
index 5529391..f9ae799 100644
--- a/ppapi/example/example.cc
+++ b/ppapi/example/example.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -12,6 +12,7 @@
#include <algorithm>
#include "ppapi/c/dev/ppb_console_dev.h"
+#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppp_printing_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/pp_input_event.h"
@@ -163,7 +164,8 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
width_(0),
height_(0),
animation_counter_(0),
- print_settings_valid_(false) {}
+ print_settings_valid_(false),
+ showing_custom_cursor_(false) {}
virtual ~MyInstance() {
if (fetcher_) {
@@ -194,6 +196,7 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
switch (event.type) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
SayHello();
+ ToggleCursor();
return true;
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
return true;
@@ -395,6 +398,30 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
fetcher_ = NULL;
}
+ void ToggleCursor() {
+ const PPB_CursorControl_Dev* cursor_control =
+ reinterpret_cast<const PPB_CursorControl_Dev*>(
+ pp::Module::Get()->GetBrowserInterface(
+ PPB_CURSOR_CONTROL_DEV_INTERFACE));
+ if (!cursor_control)
+ return;
+
+ if (showing_custom_cursor_) {
+ cursor_control->SetCursor(pp_instance(), PP_CURSORTYPE_POINTER, 0, NULL);
+ } else {
+ pp::ImageData image_data(this, pp::ImageData::GetNativeImageDataFormat(),
+ pp::Size(50, 50), false);
+ FillRect(&image_data, 0, 0, 50, 50,
+ image_data.format() == PP_IMAGEDATAFORMAT_BGRA_PREMUL ?
+ 0x80800000 : 0x80000080);
+ pp::Point hot_spot(0, 0);
+ cursor_control->SetCursor(pp_instance(), PP_CURSORTYPE_CUSTOM,
+ image_data.pp_resource(), &hot_spot.pp_point());
+ }
+
+ showing_custom_cursor_ = !showing_custom_cursor_;
+ }
+
pp::Var console_;
pp::Graphics2D device_context_;
@@ -409,6 +436,8 @@ class MyInstance : public pp::Instance, public MyFetcherClient {
int animation_counter_;
bool print_settings_valid_;
PP_PrintSettings_Dev print_settings_;
+
+ bool showing_custom_cursor_;
};
void FlushCallback(void* data, int32_t result) {