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

Unified Diff: chrome/common/extensions/icon_transform.cc

Issue 10703090: Turn pageAction.show -> browserAction.sensibleThing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: views (incomplete) Created 8 years, 5 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
« no previous file with comments | « chrome/common/extensions/icon_transform.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/icon_transform.cc
diff --git a/chrome/common/extensions/icon_transform.cc b/chrome/common/extensions/icon_transform.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7c45136e181c9c9f9d65fc1f55a08a9a6c91139a
--- /dev/null
+++ b/chrome/common/extensions/icon_transform.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2012 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 "chrome/common/extensions/icon_transform.h"
+
+#include "base/logging.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkDevice.h"
+#include "third_party/skia/include/core/SkPaint.h"
+
+namespace extensions {
+
+IconTransform::IconTransform() : alpha_(0) {
+}
+
+IconTransform::~IconTransform() {
+}
+
+const SkBitmap& IconTransform::RenderIcon(const SkBitmap& icon) {
+ DCHECK_GT(icon.width(), 0);
+ DCHECK_GT(icon.height(), 0);
+
+ if (!device_.get() ||
+ (device_->width() != icon.width()) ||
+ (device_->height() != icon.height())) {
+ device_.reset(new SkDevice(
+ SkBitmap::kARGB_8888_Config, icon.width(), icon.height(), true));
+ }
+
+ SkCanvas canvas(device_.get());
+ canvas.clear(0);
+ SkPaint paint;
+ paint.setAlpha(alpha_);
+ canvas.drawBitmap(icon, 0, 0, &paint);
+ return device_->accessBitmap(false);
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/common/extensions/icon_transform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698