| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/app_menu.h" | 5 #include "chrome/browser/ui/views/toolbar/app_menu.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 color_(color) { | 380 color_(color) { |
| 381 } | 381 } |
| 382 ~HoveredImageSource() override {} | 382 ~HoveredImageSource() override {} |
| 383 | 383 |
| 384 gfx::ImageSkiaRep GetImageForScale(float scale) override { | 384 gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 385 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); | 385 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); |
| 386 SkBitmap bitmap = rep.sk_bitmap(); | 386 SkBitmap bitmap = rep.sk_bitmap(); |
| 387 SkBitmap white; | 387 SkBitmap white; |
| 388 white.allocN32Pixels(bitmap.width(), bitmap.height()); | 388 white.allocN32Pixels(bitmap.width(), bitmap.height()); |
| 389 white.eraseARGB(0, 0, 0, 0); | 389 white.eraseARGB(0, 0, 0, 0); |
| 390 bitmap.lockPixels(); | |
| 391 for (int y = 0; y < bitmap.height(); ++y) { | 390 for (int y = 0; y < bitmap.height(); ++y) { |
| 392 uint32_t* image_row = bitmap.getAddr32(0, y); | 391 uint32_t* image_row = bitmap.getAddr32(0, y); |
| 393 uint32_t* dst_row = white.getAddr32(0, y); | 392 uint32_t* dst_row = white.getAddr32(0, y); |
| 394 for (int x = 0; x < bitmap.width(); ++x) { | 393 for (int x = 0; x < bitmap.width(); ++x) { |
| 395 uint32_t image_pixel = image_row[x]; | 394 uint32_t image_pixel = image_row[x]; |
| 396 // Fill the non transparent pixels with |color_|. | 395 // Fill the non transparent pixels with |color_|. |
| 397 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_; | 396 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_; |
| 398 } | 397 } |
| 399 } | 398 } |
| 400 bitmap.unlockPixels(); | |
| 401 return gfx::ImageSkiaRep(white, scale); | 399 return gfx::ImageSkiaRep(white, scale); |
| 402 } | 400 } |
| 403 | 401 |
| 404 private: | 402 private: |
| 405 const gfx::ImageSkia image_; | 403 const gfx::ImageSkia image_; |
| 406 const SkColor color_; | 404 const SkColor color_; |
| 407 DISALLOW_COPY_AND_ASSIGN(HoveredImageSource); | 405 DISALLOW_COPY_AND_ASSIGN(HoveredImageSource); |
| 408 }; | 406 }; |
| 409 | 407 |
| 410 } // namespace | 408 } // namespace |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 0, | 1226 0, |
| 1229 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 1227 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
| 1230 BOOKMARK_LAUNCH_LOCATION_APP_MENU); | 1228 BOOKMARK_LAUNCH_LOCATION_APP_MENU); |
| 1231 } | 1229 } |
| 1232 | 1230 |
| 1233 int AppMenu::ModelIndexFromCommandId(int command_id) const { | 1231 int AppMenu::ModelIndexFromCommandId(int command_id) const { |
| 1234 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); | 1232 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); |
| 1235 DCHECK(ix != command_id_to_entry_.end()); | 1233 DCHECK(ix != command_id_to_entry_.end()); |
| 1236 return ix->second.second; | 1234 return ix->second.second; |
| 1237 } | 1235 } |
| OLD | NEW |