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

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: 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() { 305 bool HasLoaded2xResources() {
306 return gfx::Display::GetForcedDeviceScaleFactor() > 1.0f || 306 return gfx::Display::GetForcedDeviceScaleFactor() > 1.0f;
pkotwicz 2012/08/07 16:04:58 Remove this function
flackr 2012/08/07 18:47:50 Done.
307 CommandLine::ForCurrentProcess()->HasSwitch(switches::kLoad2xResources);
308 } 307 }
309 308
310 } // namespace 309 } // namespace
311 310
312 // A utility class that provides X Cursor for NativeCursors for which we have 311 // A utility class that provides X Cursor for NativeCursors for which we have
313 // image resources. 312 // image resources.
314 class RootWindowHostLinux::ImageCursors { 313 class RootWindowHostLinux::ImageCursors {
315 public: 314 public:
316 ImageCursors() : scale_factor_(0.0) { 315 ImageCursors() : scale_factor_(0.0) {
317 } 316 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return cursors_[type]; 401 return cursors_[type];
403 } 402 }
404 403
405 private: 404 private:
406 // Creates an X Cursor from an image resource and puts it in the cursor map. 405 // 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) { 406 void LoadImageCursor(int id, int resource_id, int hot_x, int hot_y) {
408 const gfx::ImageSkia* image = 407 const gfx::ImageSkia* image =
409 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 408 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
410 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation( 409 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
411 ui::GetScaleFactorFromScale(scale_factor_)); 410 ui::GetScaleFactorFromScale(scale_factor_));
412 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale()); 411 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale());
pkotwicz 2012/08/07 16:04:58 Remove this DCHECK
flackr 2012/08/07 18:47:50 Done.
413 gfx::Point hot(hot_x * scale_factor_, hot_y * scale_factor_); 412 gfx::Point hot(hot_x * scale_factor_, hot_y * scale_factor_);
414 XcursorImage* x_image = 413 XcursorImage* x_image =
415 ui::SkBitmapToXcursorImage(&image_rep.sk_bitmap(), hot); 414 ui::SkBitmapToXcursorImage(&image_rep.sk_bitmap(), hot);
416 cursors_[id] = ui::CreateReffedCustomXCursor(x_image); 415 cursors_[id] = ui::CreateReffedCustomXCursor(x_image);
417 // |bitmap| is owned by the resource bundle. So we do not need to free it. 416 // |bitmap| is owned by the resource bundle. So we do not need to free it.
418 } 417 }
419 418
420 // Creates an animated X Cursor from an image resource and puts it in the 419 // 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. 420 // cursor map. The image is assumed to be a concatenation of animation frames.
422 // Also, each frame is assumed to be square (width == height) 421 // Also, each frame is assumed to be square (width == height)
423 void LoadAnimatedCursor(int id, int resource_id, int hot_x, int hot_y) { 422 void LoadAnimatedCursor(int id, int resource_id, int hot_x, int hot_y) {
424 const gfx::ImageSkia* image = 423 const gfx::ImageSkia* image =
425 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); 424 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
426 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation( 425 const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
427 ui::GetScaleFactorFromScale(scale_factor_)); 426 ui::GetScaleFactorFromScale(scale_factor_));
428 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale()); 427 DCHECK(!HasLoaded2xResources() || scale_factor_ == image_rep.GetScale());
pkotwicz 2012/08/07 16:04:58 Remove this DCHECK as well
flackr 2012/08/07 18:47:50 Done.
429 const SkBitmap bitmap = image_rep.sk_bitmap(); 428 const SkBitmap bitmap = image_rep.sk_bitmap();
430 DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config); 429 DCHECK_EQ(bitmap.config(), SkBitmap::kARGB_8888_Config);
431 int frame_width = bitmap.height(); 430 int frame_width = bitmap.height();
432 int frame_height = frame_width; 431 int frame_height = frame_width;
433 int total_width = bitmap.width(); 432 int total_width = bitmap.width();
434 DCHECK_EQ(total_width % frame_width, 0); 433 DCHECK_EQ(total_width % frame_width, 0);
435 int frame_count = total_width / frame_width; 434 int frame_count = total_width / frame_width;
436 DCHECK_GT(frame_count, 0); 435 DCHECK_GT(frame_count, 0);
437 XcursorImages* x_images = XcursorImagesCreate(frame_count); 436 XcursorImages* x_images = XcursorImagesCreate(frame_count);
438 x_images->nimage = frame_count; 437 x_images->nimage = frame_count;
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); 1060 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey));
1062 } 1061 }
1063 1062
1064 // static 1063 // static
1065 gfx::Size RootWindowHost::GetNativeScreenSize() { 1064 gfx::Size RootWindowHost::GetNativeScreenSize() {
1066 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay(); 1065 ::Display* xdisplay = base::MessagePumpAuraX11::GetDefaultXDisplay();
1067 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); 1066 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0));
1068 } 1067 }
1069 1068
1070 } // namespace aura 1069 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698