Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1132)

Unified Diff: ui/base/cursor/cursor_loader_ozone.cc

Issue 158023006: Adding Ozone CursorLoader and necessary API functions to allow setting the cursor in SoftwareFactor… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/cursor/cursor_loader_ozone.cc
diff --git a/ui/base/cursor/cursor_loader_ozone.cc b/ui/base/cursor/cursor_loader_ozone.cc
new file mode 100644
index 0000000000000000000000000000000000000000..684dd22b491318f10e7db2ca07cec8b79ad98ccd
--- /dev/null
+++ b/ui/base/cursor/cursor_loader_ozone.cc
@@ -0,0 +1,70 @@
+// Copyright 2014 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 "ui/base/cursor/cursor_loader_ozone.h"
+
+#include "ui/base/cursor/cursor.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace ui {
+
+namespace {
+
+// Creates a 1x1 cursor which will be fully transparent.
+SkBitmap CreateInvisibleCursor() {
+ SkBitmap cursor;
+ cursor.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
+ cursor.allocPixels();
+
+ cursor.lockPixels();
+ cursor.eraseARGB(0, 0, 0, 0);
+ cursor.unlockPixels();
+
+ return cursor;
+}
+
+} // namespace
+
+CursorLoaderOzone::CursorLoaderOzone() {
+ cursors_[kCursorNone] = CreateInvisibleCursor();
+}
+
+CursorLoaderOzone::~CursorLoaderOzone() {}
+
+void CursorLoaderOzone::LoadImageCursor(int id,
rjkroege 2014/02/11 21:57:55 this code as written never removes cursors. how ar
dnicoara 2014/02/12 16:18:19 I've added a call to clear in UnloadAll. It wasn't
+ int resource_id,
+ const gfx::Point& hot) {
+ const gfx::ImageSkia* image = ResourceBundle::GetSharedInstance()
+ .GetImageSkiaNamed(resource_id);
+ const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
+ display().device_scale_factor());
+
+ cursors_[id] = image_rep.sk_bitmap();
+}
+
+void CursorLoaderOzone::LoadAnimatedCursor(int id,
+ int resource_id,
+ const gfx::Point& hot,
+ int frame_delay_ms) {
+ NOTIMPLEMENTED();
+}
+
+void CursorLoaderOzone::UnloadAll() {}
+
+void CursorLoaderOzone::SetPlatformCursor(gfx::NativeCursor* cursor) {
+ if (cursors_.find(cursor->native_type()) != cursors_.end()) {
+ cursor->SetPlatformCursor(&cursors_[cursor->native_type()]);
+ } else if (*cursor == kCursorCustom) {
+ cursor->SetPlatformCursor(cursor->platform());
+ } else {
+ cursor->SetPlatformCursor(&cursors_[kCursorPointer]);
+ }
+}
+
+CursorLoader* CursorLoader::Create() {
+ return new CursorLoaderOzone();
+}
+
+} // namespace ui
« no previous file with comments | « ui/base/cursor/cursor_loader_ozone.h ('k') | ui/base/cursor/cursor_ozone.cc » ('j') | ui/ui.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698