Commit f579c56a authored by Eric Karl's avatar Eric Karl Committed by Commit Bot

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/815897Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Commit-Queue: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523216}
parent bf713982
......@@ -8,6 +8,8 @@ import("//testing/libfuzzer/fuzzer_test.gni")
cc_component("paint") {
output_name = "cc_paint"
sources = [
"decode_stashing_image_provider.cc",
"decode_stashing_image_provider.h",
"decoded_draw_image.cc",
"decoded_draw_image.h",
"discardable_image_map.cc",
......
// 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
// 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_
......@@ -8,28 +8,6 @@
#include "cc/paint/paint_image_builder.h"
namespace cc {
ScopedRasterFlags::DecodeStashingImageProvider::DecodeStashingImageProvider(
ImageProvider* source_provider)
: source_provider_(source_provider) {
DCHECK(source_provider_);
}
ScopedRasterFlags::DecodeStashingImageProvider::~DecodeStashingImageProvider() =
default;
ImageProvider::ScopedDecodedDrawImage
ScopedRasterFlags::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;
}
ScopedRasterFlags::ScopedRasterFlags(const PaintFlags* flags,
ImageProvider* image_provider,
const SkMatrix& ctm,
......
......@@ -7,7 +7,7 @@
#include "base/containers/stack_container.h"
#include "base/macros.h"
#include "cc/paint/image_provider.h"
#include "cc/paint/decode_stashing_image_provider.h"
#include "cc/paint/paint_export.h"
#include "cc/paint/paint_flags.h"
......@@ -34,26 +34,6 @@ class CC_PAINT_EXPORT ScopedRasterFlags {
}
private:
// 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);
};
void DecodeImageShader(const SkMatrix& ctm);
void DecodeRecordShader(const SkMatrix& ctm);
void AdjustStrokeIfNeeded(const SkMatrix& ctm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment