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

Unified Diff: ui/android/resources/nine_patch_resource.cc

Issue 2752693003: chrome/android: Update toolbar drawing in native. (Closed)
Patch Set: .. Created 3 years, 9 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 | « ui/android/resources/nine_patch_resource.h ('k') | ui/android/resources/resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/resources/nine_patch_resource.cc
diff --git a/ui/android/resources/nine_patch_resource.cc b/ui/android/resources/nine_patch_resource.cc
index cf8055dd40c02741cabd49f5f0faecbcc03a2ec9..5a8ff78e66073f9ed60fecaa74bc3c31a4315ef3 100644
--- a/ui/android/resources/nine_patch_resource.cc
+++ b/ui/android/resources/nine_patch_resource.cc
@@ -5,6 +5,8 @@
#include "ui/android/resources/nine_patch_resource.h"
#include "base/memory/ptr_util.h"
+#include "cc/layers/nine_patch_layer.h"
+#include "ui/gfx/geometry/point_f.h"
namespace ui {
@@ -21,6 +23,22 @@ NinePatchResource::NinePatchResource(gfx::Rect padding, gfx::Rect aperture)
NinePatchResource::~NinePatchResource() = default;
+gfx::Size NinePatchResource::DrawSize(const gfx::Size& content_size) const {
+ // The effective drawing size of the resource includes the size of the content
+ // (fit inside the expanded padding area) and the size of the margins on each
+ // side.
+ return gfx::Size(content_size.width() + size().width() - padding_.width(),
+ content_size.height() + size().height() - padding_.height());
+}
+
+gfx::PointF NinePatchResource::DrawPosition(
+ const gfx::Point& content_position) const {
+ // Offset the location of the layer by the amount taken by the left and top
+ // margin.
+ return gfx::PointF(content_position.x() - padding_.x(),
+ content_position.y() - padding_.y());
+}
+
gfx::Rect NinePatchResource::Border(const gfx::Size& bounds) const {
return Border(bounds, gfx::InsetsF(1.f, 1.f, 1.f, 1.f));
}
« no previous file with comments | « ui/android/resources/nine_patch_resource.h ('k') | ui/android/resources/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698