video_layer.cc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2010 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. #include "cc/layers/video_layer.h"
  5. #include "cc/layers/video_layer_impl.h"
  6. namespace cc {
  7. scoped_refptr<VideoLayer> VideoLayer::Create(
  8. VideoFrameProvider* provider,
  9. media::VideoTransformation transform) {
  10. return base::WrapRefCounted(new VideoLayer(provider, transform));
  11. }
  12. VideoLayer::VideoLayer(VideoFrameProvider* provider,
  13. media::VideoTransformation transform)
  14. : provider_(provider), transform_(transform) {
  15. SetMayContainVideo(true);
  16. DCHECK(provider_.Read(*this));
  17. }
  18. VideoLayer::~VideoLayer() = default;
  19. std::unique_ptr<LayerImpl> VideoLayer::CreateLayerImpl(
  20. LayerTreeImpl* tree_impl) const {
  21. return VideoLayerImpl::Create(tree_impl, id(), provider_.Read(*this),
  22. transform_);
  23. }
  24. bool VideoLayer::Update() {
  25. bool updated = Layer::Update();
  26. // Video layer doesn't update any resources from the main thread side,
  27. // but repaint rects need to be sent to the VideoLayerImpl via commit.
  28. //
  29. // This is the inefficient legacy redraw path for videos. It's better to
  30. // communicate this directly to the VideoLayerImpl.
  31. updated |= !update_rect().IsEmpty();
  32. return updated;
  33. }
  34. void VideoLayer::StopUsingProvider() {
  35. provider_.Write(*this) = nullptr;
  36. }
  37. } // namespace cc