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

Unified Diff: cc/quads/nine_patch_generator.h

Issue 2591863003: Use nine-patch resource for drawing Aura overlay scrollbar thumb. (Closed)
Patch Set: Addressed sadrul@'s feedback Created 3 years, 10 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
Index: cc/quads/nine_patch_generator.h
diff --git a/cc/layers/nine_patch_layer_impl.h b/cc/quads/nine_patch_generator.h
similarity index 63%
copy from cc/layers/nine_patch_layer_impl.h
copy to cc/quads/nine_patch_generator.h
index c7a1c2e8b28010932cc7be852bdca437a260cd67..4be36540cad8f18b4fff3e592a27e47d19897845 100644
--- a/cc/layers/nine_patch_layer_impl.h
+++ b/cc/quads/nine_patch_generator.h
@@ -1,20 +1,19 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright 2016 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 CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
-#define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
+#ifndef CC_QUADS_NINE_PATCH_GENERATOR_H_
+#define CC_QUADS_NINE_PATCH_GENERATOR_H_
#include <string>
+#include <vector>
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "cc/base/cc_export.h"
-#include "cc/layers/layer_impl.h"
-#include "cc/layers/ui_resource_layer_impl.h"
-#include "cc/resources/resource_provider.h"
#include "cc/resources/ui_resource_client.h"
#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
namespace base {
@@ -23,13 +22,24 @@ class DictionaryValue;
namespace cc {
-class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl {
+class LayerImpl;
+class RenderPass;
+class SharedQuadState;
+
+class CC_EXPORT NinePatchGenerator {
public:
- static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl,
- int id) {
- return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id));
- }
- ~NinePatchLayerImpl() override;
+ class Patch {
+ public:
+ Patch(const gfx::RectF& image_rect,
+ const gfx::Size& total_image_bounds,
+ const gfx::RectF& output_rect);
+
+ gfx::RectF image_rect;
+ gfx::RectF normalized_image_rect;
+ gfx::RectF output_rect;
+ };
+
+ NinePatchGenerator();
// The bitmap stretches out the bounds of the layer. The following picture
// illustrates the parameters associated with the dimensions.
@@ -77,55 +87,45 @@ class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl {
// |border| = (A, C, A + B, C + D)
// |occlusion_rectangle| = (I, J, K, L)
// |fill_center| indicates whether to draw the center quad or not.
- void SetLayout(const gfx::Rect& image_aperture,
+ bool SetLayout(const gfx::Size& image_bounds,
+ const gfx::Size& output_bounds,
+ const gfx::Rect& image_aperture,
const gfx::Rect& border,
- const gfx::Rect& layer_occlusion,
+ const gfx::Rect& output_occlusion,
bool fill_center,
bool nearest_neighbor);
- std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
- void PushPropertiesTo(LayerImpl* layer) override;
+ std::vector<Patch> GeneratePatches() const;
- void AppendQuads(RenderPass* render_pass,
- AppendQuadsData* append_quads_data) override;
+ void AppendQuads(LayerImpl* layer_impl,
+ UIResourceId ui_resource_id,
+ RenderPass* render_pass,
+ SharedQuadState* shared_quad_state,
+ const std::vector<Patch>& patches);
- std::unique_ptr<base::DictionaryValue> LayerTreeAsJson() override;
-
- protected:
- NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id);
+ void AsJson(base::DictionaryValue* dictionary) const;
private:
- class Patch {
- public:
- Patch(const gfx::RectF& image_rect, const gfx::RectF& layer_rect);
-
- gfx::RectF image_rect;
- gfx::RectF layer_rect;
- };
-
- const char* LayerTypeAsString() const override;
-
void CheckGeometryLimitations();
std::vector<Patch> ComputeQuadsWithOcclusion() const;
std::vector<Patch> ComputeQuadsWithoutOcclusion() const;
- // The transparent center region that shows the parent layer's contents in
- // image space.
+ // The center patch in image space.
gfx::Rect image_aperture_;
// An inset border that the patches will be mapped to.
gfx::Rect border_;
- bool fill_center_;
+ gfx::Size image_bounds_;
+ gfx::Size output_bounds_;
+ bool fill_center_;
bool nearest_neighbor_;
- gfx::Rect layer_occlusion_;
-
- DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl);
+ gfx::Rect output_occlusion_;
};
} // namespace cc
-#endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
+#endif // CC_QUADS_NINE_PATCH_GENERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698