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

Unified Diff: cc/quads/nine_patch_generator.h

Issue 2591863003: Use nine-patch resource for drawing Aura overlay scrollbar thumb. (Closed)
Patch Set: Move CheckGeometryLimitations back to where it used to be (AppendQuads) 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
« no previous file with comments | « cc/layers/painted_overlay_scrollbar_layer_impl.cc ('k') | cc/quads/nine_patch_generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..140d361914e3a29204859b6c3e79670a38e025a4 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,44 @@ 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;
-
- void AppendQuads(RenderPass* render_pass,
- AppendQuadsData* append_quads_data) override;
-
- std::unique_ptr<base::DictionaryValue> LayerTreeAsJson() override;
+ std::vector<Patch> GeneratePatches() const;
- protected:
- NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id);
-
- 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 AppendQuads(LayerImpl* layer_impl,
+ UIResourceId ui_resource_id,
+ RenderPass* render_pass,
+ SharedQuadState* shared_quad_state,
+ const std::vector<Patch>& patches);
+ void AsJson(base::DictionaryValue* dictionary) const;
void CheckGeometryLimitations();
+ private:
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_
« no previous file with comments | « cc/layers/painted_overlay_scrollbar_layer_impl.cc ('k') | cc/quads/nine_patch_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698