Enable maximize mode when keyboard is open past 180 degrees.
[chromium-blink-merge.git] / content / common / cursors / webcursor_ozone.cc
blobabd4cf07746a047fb6379a8f163cd35a8cda4584
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/common/cursors/webcursor.h"
7 #include "third_party/WebKit/public/platform/WebCursorInfo.h"
8 #include "ui/base/cursor/cursor.h"
9 #include "ui/base/cursor/cursor_util.h"
10 #include "ui/base/cursor/ozone/cursor_factory_ozone.h"
12 namespace content {
14 const ui::PlatformCursor WebCursor::GetPlatformCursor() {
15 if (platform_cursor_)
16 return platform_cursor_;
18 SkBitmap bitmap;
19 ImageFromCustomData(&bitmap);
20 gfx::Point hotspot = hotspot_;
21 ui::ScaleAndRotateCursorBitmapAndHotpoint(
22 device_scale_factor_, rotation_, &bitmap, &hotspot);
24 return ui::CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap,
25 hotspot);
28 void WebCursor::SetDisplayInfo(const gfx::Display& display) {
29 if (rotation_ == display.rotation() &&
30 device_scale_factor_ == display.device_scale_factor())
31 return;
33 device_scale_factor_ = display.device_scale_factor();
34 rotation_ = display.rotation();
35 if (platform_cursor_)
36 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_);
37 platform_cursor_ = NULL;
38 // It is not necessary to recreate platform_cursor_ yet, since it will be
39 // recreated on demand when GetPlatformCursor is called.
42 void WebCursor::InitPlatformData() {
43 platform_cursor_ = NULL;
44 device_scale_factor_ = 1.f;
45 rotation_ = gfx::Display::ROTATE_0;
48 bool WebCursor::SerializePlatformData(Pickle* pickle) const {
49 return true;
52 bool WebCursor::DeserializePlatformData(PickleIterator* iter) {
53 return true;
56 bool WebCursor::IsPlatformDataEqual(const WebCursor& other) const {
57 return true;
60 void WebCursor::CleanupPlatformData() {
61 if (platform_cursor_) {
62 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_);
63 platform_cursor_ = NULL;
67 void WebCursor::CopyPlatformData(const WebCursor& other) {
68 if (platform_cursor_)
69 ui::CursorFactoryOzone::GetInstance()->UnrefImageCursor(platform_cursor_);
70 platform_cursor_ = other.platform_cursor_;
71 if (platform_cursor_)
72 ui::CursorFactoryOzone::GetInstance()->RefImageCursor(platform_cursor_);
74 device_scale_factor_ = other.device_scale_factor_;
77 } // namespace content