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

Side by Side Diff: ui/aura/root_window_host_linux.cc

Issue 10837142: Remove --load-2x-resources flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/root_window_host_linux.h" 5 #include "ui/aura/root_window_host_linux.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xcursor/Xcursor.h> 8 #include <X11/Xcursor/Xcursor.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/cursorfont.h> 10 #include <X11/cursorfont.h>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 case ui::VKEY_OEM_PLUS: 295 case ui::VKEY_OEM_PLUS:
296 case ui::VKEY_OEM_COMMA: 296 case ui::VKEY_OEM_COMMA:
297 case ui::VKEY_OEM_MINUS: 297 case ui::VKEY_OEM_MINUS:
298 case ui::VKEY_OEM_PERIOD: 298 case ui::VKEY_OEM_PERIOD:
299 return true; 299 return true;
300 default: 300 default:
301 return false; 301 return false;
302 } 302 }
303 } 303 }
304 304
305 bool HasLoaded2xResources() {
306 return gfx::Display::GetForcedDeviceScaleFactor() > 1.0f ||
307 CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoad2xResources);
308 }
309
310 } // namespace 305 } // namespace
311 306
312 // A utility class that provides X Cursor for NativeCursors for which we have 307 // A utility class that provides X Cursor for NativeCursors for which we have
313 // image resources. 308 // image resources.
314 class RootWindowHostLinux::ImageCursors { 309 class RootWindowHostLinux::ImageCursors {
315 public: 310 public:
316 ImageCursors() : scale_factor_(0.0) { 311 ImageCursors() : scale_factor_(0.0) {
317 } 312 }
318 313
319 void Reload(float scale_factor) { 314 void Reload(float scale_factor) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return cursors_[type]; 397 return cursors_[type];
403 } 398 }
404 399
405 private: 400 private:
406 // Creates an X Cursor from an image resource and puts it in the cursor map. 401 // Creates an X Cursor from an image resource and puts it in the cursor map.
407 void LoadImageCursor(int id, int resource_id, int hot_x, int hot_y) { 402 void LoadImageCursor(int id, int resource_id, int hot_x, int hot_y) {
408 const gfx::ImageSkia* image = 403 const gfx::ImageSkia* image =
409 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 404 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
410 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation( 405 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
411 ui::GetScaleFactorFromScale(scale_factor_)); 406 ui::GetScaleFactorFromScale(scale_factor_));
412 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale());
413 gfx::Point hot(hot_x * scale_factor_, hot_y * scale_factor_); 407 gfx::Point hot(hot_x * scale_factor_, hot_y * scale_factor_);
414 XcursorImage* x_image = 408 XcursorImage* x_image =
415 ui::SkBitmapToXcursorImage(&image_rep.sk_bitmap(), hot); 409 ui::SkBitmapToXcursorImage(&image_rep.sk_bitmap(), hot);
416 cursors_[id] = ui::CreateReffedCustomXCursor(x_image); 410 cursors_[id] = ui::CreateReffedCustomXCursor(x_image);
417 // |bitmap| is owned by the resource bundle. So we do not need to free it. 411 // |bitmap| is owned by the resource bundle. So we do not need to free it.
418 } 412 }
419 413
420 // Creates an animated X Cursor from an image resource and puts it in the 414 // Creates an animated X Cursor from an image resource and puts it in the
421 // cursor map. The image is assumed to be a concatenation of animation frames. 415 // cursor map. The image is assumed to be a concatenation of animation frames.
422 // Also, each frame is assumed to be square (width == height) 416 // Also, each frame is assumed to be square (width == height)
423 void LoadAnimatedCursor(int id, int resource_id, int hot_x, int hot_y) { 417 void LoadAnimatedCursor(int id, int resource_id, int hot_x, int hot_y) {
424 const gfx::ImageSkia* image = 418 const gfx::ImageSkia* image =
425 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 419 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
426 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation( 420 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
427 ui::GetScaleFactorFromScale(scale_factor_)); 421 ui::GetScaleFactorFromScale(scale_factor_));
428 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale());
429 const SkBitmap bitmap = image_rep.sk_bitmap(); 422 const SkBitmap bitmap = image_rep.sk_bitmap();
430 DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config); 423 DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config);
431 int frame_width = bitmap.height(); 424 int frame_width = bitmap.height();
432 int frame_height = frame_width; 425 int frame_height = frame_width;
433 int total_width = bitmap.width(); 426 int total_width = bitmap.width();
434 DCHECK_EQ(total_width % frame_width, 0); 427 DCHECK_EQ(total_width % frame_width, 0);
435 int frame_count = total_width / frame_width; 428 int frame_count = total_width / frame_width;
436 DCHECK_GT(frame_count, 0); 429 DCHECK_GT(frame_count, 0);
437 XcursorImages* x_images = XcursorImagesCreate(frame_count); 430 XcursorImages* x_images = XcursorImagesCreate(frame_count);
438 x_images->nimage = frame_count; 431 x_images->nimage = frame_count;
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); 1054 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
1062 } 1055 }
1063 1056
1064 // static 1057 // static
1065 gfx::Size RootWindowHost::GetNativeScreenSize() { 1058 gfx::Size RootWindowHost::GetNativeScreenSize() {
1066 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1059 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
1067 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1060 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1068 } 1061 }
1069 1062
1070 } // namespace aura 1063 } // namespace aura
OLDNEW
« no previous file with comments | « content/browser/zygote_host/zygote_host_impl_linux.cc ('k') | ui/base/resource/resource_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698