diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/base/cursor/ozone | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/base/cursor/ozone')
-rw-r--r-- | chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc | 49 | ||||
-rw-r--r-- | chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h | 31 |
2 files changed, 17 insertions, 63 deletions
diff --git a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc index 44037bc6142..e86f70ea603 100644 --- a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc +++ b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc @@ -7,10 +7,6 @@ #include <algorithm> #include "base/check_op.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "ui/base/cursor/cursor_lookup.h" -#include "ui/base/cursor/cursors_aura.h" -#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h" namespace ui { @@ -24,20 +20,6 @@ PlatformCursor ToPlatformCursor(BitmapCursorOzone* cursor) { return static_cast<PlatformCursor>(cursor); } -scoped_refptr<BitmapCursorOzone> CreateDefaultBitmapCursor( - mojom::CursorType type) { - Cursor cursor(type); - // Ozone must honor the lowest possible scale value, which is 1.0f. Otherwise, - // it can happen that cursor chooses wrong hotspots if max scaling value is - // set to 200p, for example. - cursor.set_image_scale_factor(1.0f); - SkBitmap bitmap = GetCursorBitmap(cursor); - gfx::Point hotspot = GetCursorHotspot(cursor); - if (!bitmap.isNull()) - return new BitmapCursorOzone(bitmap, hotspot); - return nullptr; -} - } // namespace BitmapCursorOzone::BitmapCursorOzone(const SkBitmap& bitmap, @@ -89,15 +71,16 @@ scoped_refptr<BitmapCursorOzone> BitmapCursorFactoryOzone::GetBitmapCursor( return base::WrapRefCounted(ToBitmapCursorOzone(platform_cursor)); } -PlatformCursor BitmapCursorFactoryOzone::GetDefaultCursor( +base::Optional<PlatformCursor> BitmapCursorFactoryOzone::GetDefaultCursor( mojom::CursorType type) { - return GetDefaultCursorInternal(type).get(); + if (type == mojom::CursorType::kNone) + return nullptr; // nullptr is used for the hidden cursor. + return base::nullopt; } PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor( const SkBitmap& bitmap, - const gfx::Point& hotspot, - float bitmap_dpi) { + const gfx::Point& hotspot) { BitmapCursorOzone* cursor = new BitmapCursorOzone(bitmap, hotspot); cursor->AddRef(); // Balanced by UnrefImageCursor. return ToPlatformCursor(cursor); @@ -106,8 +89,7 @@ PlatformCursor BitmapCursorFactoryOzone::CreateImageCursor( PlatformCursor BitmapCursorFactoryOzone::CreateAnimatedCursor( const std::vector<SkBitmap>& bitmaps, const gfx::Point& hotspot, - int frame_delay_ms, - float bitmap_dpi) { + int frame_delay_ms) { DCHECK_LT(0U, bitmaps.size()); BitmapCursorOzone* cursor = new BitmapCursorOzone(bitmaps, hotspot, frame_delay_ms); @@ -123,23 +105,4 @@ void BitmapCursorFactoryOzone::UnrefImageCursor(PlatformCursor cursor) { ToBitmapCursorOzone(cursor)->Release(); } -scoped_refptr<BitmapCursorOzone> -BitmapCursorFactoryOzone::GetDefaultCursorInternal(mojom::CursorType type) { - if (type == mojom::CursorType::kNone) - return nullptr; // Null is used for hidden cursor. - - if (!default_cursors_.count(type)) { - // Create new image cursor from default aura bitmap for this type. We hold a - // ref forever because clients do not do refcounting for default cursors. - scoped_refptr<BitmapCursorOzone> cursor = CreateDefaultBitmapCursor(type); - if (!cursor.get() && type != mojom::CursorType::kPointer) - cursor = GetDefaultCursorInternal(mojom::CursorType::kPointer); - DCHECK(cursor.get()) << "Failed to load default cursor bitmap"; - default_cursors_[type] = cursor; - } - - // Returned owned default cursor for this type. - return default_cursors_[type]; -} - } // namespace ui diff --git a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h index 95ed10b051b..b489e099ad0 100644 --- a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h +++ b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h @@ -5,21 +5,20 @@ #ifndef UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_ #define UI_BASE_CURSOR_OZONE_BITMAP_CURSOR_FACTORY_OZONE_H_ -#include <map> +#include <vector> +#include "base/component_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/cursor/cursor.h" -#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h" -#include "ui/base/ui_base_export.h" +#include "ui/base/cursor/cursor_factory.h" #include "ui/gfx/geometry/point.h" -#include "ui/ozone/public/cursor_factory_ozone.h" namespace ui { // A cursor that is an SkBitmap combined with a gfx::Point hotspot. -class UI_BASE_EXPORT BitmapCursorOzone +class COMPONENT_EXPORT(UI_BASE_CURSOR) BitmapCursorOzone : public base::RefCounted<BitmapCursorOzone> { public: BitmapCursorOzone(const SkBitmap& bitmap, const gfx::Point& hotspot); @@ -45,14 +44,15 @@ class UI_BASE_EXPORT BitmapCursorOzone DISALLOW_COPY_AND_ASSIGN(BitmapCursorOzone); }; -// CursorFactoryOzone implementation for bitmapped cursors. +// CursorFactory implementation for bitmapped cursors. // // This is a base class for platforms where PlatformCursor is an SkBitmap // combined with a gfx::Point for the hotspot. // // Subclasses need only implement SetBitmapCursor() as everything else is // implemented here. -class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone { +class COMPONENT_EXPORT(UI_BASE_CURSOR) BitmapCursorFactoryOzone + : public CursorFactory { public: BitmapCursorFactoryOzone(); ~BitmapCursorFactoryOzone() override; @@ -62,26 +62,17 @@ class UI_BASE_EXPORT BitmapCursorFactoryOzone : public CursorFactoryOzone { PlatformCursor platform_cursor); // CursorFactoryOzone: - PlatformCursor GetDefaultCursor(mojom::CursorType type) override; + base::Optional<PlatformCursor> GetDefaultCursor( + mojom::CursorType type) override; PlatformCursor CreateImageCursor(const SkBitmap& bitmap, - const gfx::Point& hotspot, - float bitmap_dpi) override; + const gfx::Point& hotspot) override; PlatformCursor CreateAnimatedCursor(const std::vector<SkBitmap>& bitmaps, const gfx::Point& hotspot, - int frame_delay_ms, - float bitmap_dpi) override; + int frame_delay_ms) override; void RefImageCursor(PlatformCursor cursor) override; void UnrefImageCursor(PlatformCursor cursor) override; private: - // Get cached BitmapCursorOzone for a default cursor. - scoped_refptr<BitmapCursorOzone> GetDefaultCursorInternal( - mojom::CursorType type); - - // Default cursors are cached & owned by the factory. - std::map<mojom::CursorType, scoped_refptr<BitmapCursorOzone>> - default_cursors_; - DISALLOW_COPY_AND_ASSIGN(BitmapCursorFactoryOzone); }; |