summaryrefslogtreecommitdiffstats
path: root/ui/gfx/shadow_value.h
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 02:23:56 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 02:23:56 +0000
commit0834e1b153c28dec0ae9e90080ad7a106f1c8c84 (patch)
tree3a939399a68c91722271573bf2589266d642d58f /ui/gfx/shadow_value.h
parentc8678d8870826350577c3f00e922e442abb647c9 (diff)
downloadchromium_src-0834e1b153c28dec0ae9e90080ad7a106f1c8c84.zip
chromium_src-0834e1b153c28dec0ae9e90080ad7a106f1c8c84.tar.gz
chromium_src-0834e1b153c28dec0ae9e90080ad7a106f1c8c84.tar.bz2
ash: Better and faster text shadows.
- Add a DrawStringWithShadows that draws text with shadows to canvas skia and RenderText; - Use DrawStringWithShadows in DropShadowLabel for better and faster text shadows; BUG=121694 TEST=Verify fix for issue 121694. Review URL: http://codereview.chromium.org/10008027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/shadow_value.h')
-rw-r--r--ui/gfx/shadow_value.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/ui/gfx/shadow_value.h b/ui/gfx/shadow_value.h
new file mode 100644
index 0000000..8ca9196
--- /dev/null
+++ b/ui/gfx/shadow_value.h
@@ -0,0 +1,58 @@
+// 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.
+
+#ifndef UI_GFX_SHADOW_VALUE_
+#define UI_GFX_SHADOW_VALUE_
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/base/ui_export.h"
+#include "ui/gfx/point.h"
+
+namespace gfx {
+
+class Insets;
+
+// ShadowValue encapsulates parameters needed to define a shadow, including the
+// shadow's offset, blur amount and color.
+class UI_EXPORT ShadowValue {
+ public:
+ ShadowValue();
+ ShadowValue(const gfx::Point& offset, double blur, SkColor color);
+ ~ShadowValue();
+
+ int x() const { return offset_.x(); }
+ int y() const { return offset_.y(); }
+ const gfx::Point& offset() const { return offset_; }
+ double blur() const { return blur_; }
+ SkColor color() const { return color_; }
+
+ std::string ToString() const;
+
+ // Gets margin space needed for shadows. Note that values in returned Insets
+ // are negative because shadow margins are outside a boundary.
+ static Insets GetMargin(const std::vector<ShadowValue>& shadows);
+
+ private:
+ gfx::Point offset_;
+
+ // Blur amount of the shadow in pixels. If underlying implementation supports
+ // (e.g. Skia), it can have fraction part such as 0.5 pixel. The value
+ // defines a range from full shadow color at the start point inside the
+ // shadow to fully transparent at the end point outside it. The range is
+ // perpendicular to and centered on the shadow edge. For example, a blur
+ // amount of 4.0 means to have a blurry shadow edge of 4 pixels that
+ // transitions from full shadow color to fully transparent and with 2 pixels
+ // inside the shadow and 2 pixels goes beyond the edge.
+ double blur_;
+
+ SkColor color_;
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_SHADOW_VALUE_