forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DecodeStashingImageProvider into its own file.
This lets it be used outside of ScopedImageFlags. OOP raster will use this more generally during serialization. Bug: 777628 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel Change-Id: Ie1bd3dda646d6094601050263560578d4a96b09f Reviewed-on: https://chromium-review.googlesource.com/815897 Reviewed-by: vmpstr <vmpstr@chromium.org> Commit-Queue: Eric Karl <ericrk@chromium.org> Cr-Commit-Position: refs/heads/master@{#523216}
- Loading branch information
Eric Karl
authored and
Commit Bot
committed
Dec 11, 2017
1 parent
bf71398
commit f579c56
Showing
5 changed files
with
65 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2017 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. | ||
|
||
#include "cc/paint/decode_stashing_image_provider.h" | ||
|
||
namespace cc { | ||
DecodeStashingImageProvider::DecodeStashingImageProvider( | ||
ImageProvider* source_provider) | ||
: source_provider_(source_provider) { | ||
DCHECK(source_provider_); | ||
} | ||
DecodeStashingImageProvider::~DecodeStashingImageProvider() = default; | ||
|
||
ImageProvider::ScopedDecodedDrawImage | ||
DecodeStashingImageProvider::GetDecodedDrawImage(const DrawImage& draw_image) { | ||
auto decode = source_provider_->GetDecodedDrawImage(draw_image); | ||
if (!decode) | ||
return ScopedDecodedDrawImage(); | ||
|
||
// No need to add any destruction callback to the returned image. The images | ||
// decoded here match the lifetime of this provider. | ||
auto image_to_return = ScopedDecodedDrawImage(decode.decoded_image()); | ||
decoded_images_->push_back(std::move(decode)); | ||
return image_to_return; | ||
} | ||
|
||
} // namespace cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2017 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_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_ | ||
#define CC_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_ | ||
|
||
#include "base/containers/stack_container.h" | ||
#include "cc/paint/image_provider.h" | ||
|
||
namespace cc { | ||
// An ImageProvider that passes decode requests through to the | ||
// |source_provider| but keeps the decode cached throughtout its lifetime, | ||
// instead of passing the ref to the caller. | ||
class DecodeStashingImageProvider : public ImageProvider { | ||
public: | ||
// |source_provider| must outlive this class. | ||
explicit DecodeStashingImageProvider(ImageProvider* source_provider); | ||
~DecodeStashingImageProvider() override; | ||
|
||
// ImageProvider implementation. | ||
ScopedDecodedDrawImage GetDecodedDrawImage( | ||
const DrawImage& draw_image) override; | ||
|
||
private: | ||
ImageProvider* source_provider_; | ||
base::StackVector<ScopedDecodedDrawImage, 1> decoded_images_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(DecodeStashingImageProvider); | ||
}; | ||
|
||
} // namespace cc | ||
|
||
#endif // CC_PAINT_DECODE_STASHING_IMAGE_PROVIDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters