ui_resource_layer_impl.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef CC_LAYERS_UI_RESOURCE_LAYER_IMPL_H_
  5. #define CC_LAYERS_UI_RESOURCE_LAYER_IMPL_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/memory/ptr_util.h"
  9. #include "cc/cc_export.h"
  10. #include "cc/layers/layer_impl.h"
  11. #include "cc/resources/ui_resource_client.h"
  12. #include "ui/gfx/geometry/rect.h"
  13. #include "ui/gfx/geometry/size.h"
  14. namespace viz {
  15. class ClientResourceProvider;
  16. }
  17. namespace cc {
  18. class CC_EXPORT UIResourceLayerImpl : public LayerImpl {
  19. public:
  20. static std::unique_ptr<UIResourceLayerImpl> Create(LayerTreeImpl* tree_impl,
  21. int id) {
  22. return base::WrapUnique(new UIResourceLayerImpl(tree_impl, id));
  23. }
  24. UIResourceLayerImpl(const UIResourceLayerImpl&) = delete;
  25. ~UIResourceLayerImpl() override;
  26. UIResourceLayerImpl& operator=(const UIResourceLayerImpl&) = delete;
  27. void SetUIResourceId(UIResourceId uid);
  28. void SetImageBounds(const gfx::Size& image_bounds);
  29. // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1).
  30. void SetUV(const gfx::PointF& top_left, const gfx::PointF& bottom_right);
  31. // Sets an opacity value per vertex. It will be multiplied by the layer
  32. // opacity value.
  33. void SetVertexOpacity(const float vertex_opacity[4]);
  34. std::unique_ptr<LayerImpl> CreateLayerImpl(
  35. LayerTreeImpl* tree_impl) const override;
  36. void PushPropertiesTo(LayerImpl* layer) override;
  37. bool WillDraw(DrawMode draw_mode,
  38. viz::ClientResourceProvider* resource_provider) override;
  39. void AppendQuads(viz::CompositorRenderPass* render_pass,
  40. AppendQuadsData* append_quads_data) override;
  41. void AsValueInto(base::trace_event::TracedValue* state) const override;
  42. protected:
  43. UIResourceLayerImpl(LayerTreeImpl* tree_impl, int id);
  44. // The size of the resource bitmap in pixels.
  45. gfx::Size image_bounds_;
  46. UIResourceId ui_resource_id_;
  47. gfx::PointF uv_top_left_;
  48. gfx::PointF uv_bottom_right_;
  49. float vertex_opacity_[4];
  50. private:
  51. const char* LayerTypeAsString() const override;
  52. };
  53. } // namespace cc
  54. #endif // CC_LAYERS_UI_RESOURCE_LAYER_IMPL_H_