| OLD | NEW |
| 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 "chrome/browser/ui/app_list/extension_app_item.h" | 5 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 private: | 79 private: |
| 80 // gfx::CanvasImageSource overrides: | 80 // gfx::CanvasImageSource overrides: |
| 81 void Draw(gfx::Canvas* canvas) override { | 81 void Draw(gfx::Canvas* canvas) override { |
| 82 // The radius used to round the app icon. | 82 // The radius used to round the app icon. |
| 83 const size_t kRoundingRadius = 2; | 83 const size_t kRoundingRadius = 2; |
| 84 | 84 |
| 85 canvas->DrawImageInt(icon_, 0, 0); | 85 canvas->DrawImageInt(icon_, 0, 0); |
| 86 | 86 |
| 87 SkBitmap mask_bitmap; | 87 SkBitmap mask_bitmap; |
| 88 mask_bitmap.allocN32Pixels(icon_.width(), icon_.height(), false); | 88 mask_bitmap.allocN32Pixels(icon_.width(), icon_.height(), false); |
| 89 sk_sp<SkSurface> mask_surface = SkSurface::MakeRasterDirect( | 89 SkCanvas mask_canvas(mask_bitmap); |
| 90 mask_bitmap.info(), mask_bitmap.getPixels(), mask_bitmap.rowBytes()); | 90 mask_canvas.clear(SK_ColorTRANSPARENT); |
| 91 mask_surface->getCanvas()->clear(SK_ColorTRANSPARENT); | |
| 92 SkPaint mask_paint; | 91 SkPaint mask_paint; |
| 93 mask_paint.setAntiAlias(true); | 92 mask_paint.setAntiAlias(true); |
| 94 mask_paint.setColor(SK_ColorWHITE); | 93 mask_paint.setColor(SK_ColorWHITE); |
| 95 mask_surface->getCanvas()->drawRoundRect( | 94 mask_canvas.drawRoundRect( |
| 96 gfx::RectToSkRect(gfx::Rect(icon_.width(), icon_.height())), | 95 gfx::RectToSkRect(gfx::Rect(icon_.width(), icon_.height())), |
| 97 kRoundingRadius, kRoundingRadius, mask_paint); | 96 kRoundingRadius, kRoundingRadius, mask_paint); |
| 98 | 97 |
| 99 cc::PaintFlags masking_flags; | 98 cc::PaintFlags masking_flags; |
| 100 masking_flags.setBlendMode(SkBlendMode::kDstIn); | 99 masking_flags.setBlendMode(SkBlendMode::kDstIn); |
| 101 canvas->sk_canvas()->drawBitmap(mask_bitmap, 0, 0, &masking_flags); | 100 canvas->sk_canvas()->drawBitmap(mask_bitmap, 0, 0, &masking_flags); |
| 102 } | 101 } |
| 103 | 102 |
| 104 gfx::ImageSkia icon_; | 103 gfx::ImageSkia icon_; |
| 105 | 104 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // static | 307 // static |
| 309 const char ExtensionAppItem::kItemType[] = "ExtensionAppItem"; | 308 const char ExtensionAppItem::kItemType[] = "ExtensionAppItem"; |
| 310 | 309 |
| 311 const char* ExtensionAppItem::GetItemType() const { | 310 const char* ExtensionAppItem::GetItemType() const { |
| 312 return ExtensionAppItem::kItemType; | 311 return ExtensionAppItem::kItemType; |
| 313 } | 312 } |
| 314 | 313 |
| 315 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { | 314 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { |
| 316 Launch(event_flags); | 315 Launch(event_flags); |
| 317 } | 316 } |
| OLD | NEW |