image_provider.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2017 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/paint/image_provider.h"
  5. #include "cc/paint/paint_record.h"
  6. namespace cc {
  7. ImageProvider::ScopedResult::ScopedResult() = default;
  8. ImageProvider::ScopedResult::ScopedResult(DecodedDrawImage image)
  9. : image_(std::move(image)) {}
  10. ImageProvider::ScopedResult::ScopedResult(sk_sp<PaintRecord> record)
  11. : record_(std::move(record)) {}
  12. ImageProvider::ScopedResult::ScopedResult(DecodedDrawImage image,
  13. DestructionCallback callback)
  14. : image_(std::move(image)), destruction_callback_(std::move(callback)) {}
  15. ImageProvider::ScopedResult::ScopedResult(ScopedResult&& other)
  16. : image_(std::move(other.image_)),
  17. record_(std::move(other.record_)),
  18. destruction_callback_(std::move(other.destruction_callback_)) {}
  19. ImageProvider::ScopedResult& ImageProvider::ScopedResult::operator=(
  20. ScopedResult&& other) {
  21. DestroyDecode();
  22. image_ = std::move(other.image_);
  23. record_ = std::move(other.record_);
  24. destruction_callback_ = std::move(other.destruction_callback_);
  25. return *this;
  26. }
  27. ImageProvider::ScopedResult::~ScopedResult() {
  28. DestroyDecode();
  29. }
  30. void ImageProvider::ScopedResult::DestroyDecode() {
  31. if (!destruction_callback_.is_null())
  32. std::move(destruction_callback_).Run();
  33. }
  34. } // namespace cc