summaryrefslogtreecommitdiff
path: root/chromium/skia/ext
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-01-29 16:35:13 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-02-01 15:33:35 +0000
commitc8c2d1901aec01e934adf561a9fdf0cc776cdef8 (patch)
tree9157c3d9815e5870799e070b113813bec53e0535 /chromium/skia/ext
parentabefd5095b41dac94ca451d784ab6e27372e981a (diff)
downloadqtwebengine-chromium-c8c2d1901aec01e934adf561a9fdf0cc776cdef8.tar.gz
BASELINE: Update Chromium to 64.0.3282.139
Change-Id: I1cae68fe9c94ff7608b26b8382fc19862cdb293a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/skia/ext')
-rw-r--r--chromium/skia/ext/SkDiscardableMemory_chrome.cc2
-rw-r--r--chromium/skia/ext/analysis_canvas.cc4
-rw-r--r--chromium/skia/ext/benchmarking_canvas.cc3
-rw-r--r--chromium/skia/ext/convolver.cc3
-rw-r--r--chromium/skia/ext/skia_commit_hash.h2
-rw-r--r--chromium/skia/ext/skia_memory_dump_provider.cc4
-rw-r--r--chromium/skia/ext/skia_trace_memory_dump_impl.cc2
-rw-r--r--chromium/skia/ext/skia_utils_base.cc42
-rw-r--r--chromium/skia/ext/skia_utils_base.h12
-rw-r--r--chromium/skia/ext/skia_utils_base_unittest.cc103
10 files changed, 143 insertions, 34 deletions
diff --git a/chromium/skia/ext/SkDiscardableMemory_chrome.cc b/chromium/skia/ext/SkDiscardableMemory_chrome.cc
index 76923b9e563..90adda1ea0b 100644
--- a/chromium/skia/ext/SkDiscardableMemory_chrome.cc
+++ b/chromium/skia/ext/SkDiscardableMemory_chrome.cc
@@ -11,7 +11,7 @@
#include "base/memory/discardable_memory.h"
#include "base/memory/discardable_memory_allocator.h"
-SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() {}
+SkDiscardableMemoryChrome::~SkDiscardableMemoryChrome() = default;
bool SkDiscardableMemoryChrome::lock() {
return discardable_->Lock();
diff --git a/chromium/skia/ext/analysis_canvas.cc b/chromium/skia/ext/analysis_canvas.cc
index 0943444473a..cd98ee75c95 100644
--- a/chromium/skia/ext/analysis_canvas.cc
+++ b/chromium/skia/ext/analysis_canvas.cc
@@ -340,7 +340,7 @@ AnalysisCanvas::AnalysisCanvas(int width, int height)
draw_op_count_(0),
rejected_op_count_(0) {}
-AnalysisCanvas::~AnalysisCanvas() {}
+AnalysisCanvas::~AnalysisCanvas() = default;
bool AnalysisCanvas::GetColorIfSolid(SkColor* color) const {
if (is_transparent_) {
@@ -401,8 +401,6 @@ void AnalysisCanvas::onClipPath(const SkPath& path,
bool doesCoverCanvas(const SkRRect& rr,
const SkMatrix& total_matrix,
const SkIRect& clip_device_bounds) {
- const SkRect& bounding_rect = rr.rect();
-
// We cannot handle non axis aligned rectangles at the moment.
if (!total_matrix.isScaleTranslate()) {
return false;
diff --git a/chromium/skia/ext/benchmarking_canvas.cc b/chromium/skia/ext/benchmarking_canvas.cc
index 1f46938173f..053839e0055 100644
--- a/chromium/skia/ext/benchmarking_canvas.cc
+++ b/chromium/skia/ext/benchmarking_canvas.cc
@@ -429,8 +429,7 @@ BenchmarkingCanvas::BenchmarkingCanvas(SkCanvas* canvas)
addCanvas(canvas);
}
-BenchmarkingCanvas::~BenchmarkingCanvas() {
-}
+BenchmarkingCanvas::~BenchmarkingCanvas() = default;
size_t BenchmarkingCanvas::CommandCount() const {
return op_records_.GetSize();
diff --git a/chromium/skia/ext/convolver.cc b/chromium/skia/ext/convolver.cc
index 092fefaa9b6..de031465c36 100644
--- a/chromium/skia/ext/convolver.cc
+++ b/chromium/skia/ext/convolver.cc
@@ -261,8 +261,7 @@ ConvolutionFilter1D::ConvolutionFilter1D()
: max_filter_(0) {
}
-ConvolutionFilter1D::~ConvolutionFilter1D() {
-}
+ConvolutionFilter1D::~ConvolutionFilter1D() = default;
void ConvolutionFilter1D::AddFilter(int filter_offset,
const float* filter_values,
diff --git a/chromium/skia/ext/skia_commit_hash.h b/chromium/skia/ext/skia_commit_hash.h
index f5a7a58f634..22d3b2c2d1d 100644
--- a/chromium/skia/ext/skia_commit_hash.h
+++ b/chromium/skia/ext/skia_commit_hash.h
@@ -3,6 +3,6 @@
#ifndef SKIA_EXT_SKIA_COMMIT_HASH_H_
#define SKIA_EXT_SKIA_COMMIT_HASH_H_
-#define SKIA_COMMIT_HASH "1a190d213cb8f711a15d3dc489fd068cd43291bd-"
+#define SKIA_COMMIT_HASH "3638057df2d702be034b3c3421aac61888af3ba6-"
#endif // SKIA_EXT_SKIA_COMMIT_HASH_H_
diff --git a/chromium/skia/ext/skia_memory_dump_provider.cc b/chromium/skia/ext/skia_memory_dump_provider.cc
index 5c61225bd0e..2afdd8630e3 100644
--- a/chromium/skia/ext/skia_memory_dump_provider.cc
+++ b/chromium/skia/ext/skia_memory_dump_provider.cc
@@ -19,9 +19,9 @@ SkiaMemoryDumpProvider* SkiaMemoryDumpProvider::GetInstance() {
base::LeakySingletonTraits<SkiaMemoryDumpProvider>>::get();
}
-SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() {}
+SkiaMemoryDumpProvider::SkiaMemoryDumpProvider() = default;
-SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
+SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() = default;
bool SkiaMemoryDumpProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
diff --git a/chromium/skia/ext/skia_trace_memory_dump_impl.cc b/chromium/skia/ext/skia_trace_memory_dump_impl.cc
index 920fa222d99..ebdec805b5d 100644
--- a/chromium/skia/ext/skia_trace_memory_dump_impl.cc
+++ b/chromium/skia/ext/skia_trace_memory_dump_impl.cc
@@ -31,7 +31,7 @@ SkiaTraceMemoryDumpImpl::SkiaTraceMemoryDumpImpl(
? SkTraceMemoryDump::kLight_LevelOfDetail
: SkTraceMemoryDump::kObjectsBreakdowns_LevelOfDetail) {}
-SkiaTraceMemoryDumpImpl::~SkiaTraceMemoryDumpImpl() {}
+SkiaTraceMemoryDumpImpl::~SkiaTraceMemoryDumpImpl() = default;
void SkiaTraceMemoryDumpImpl::dumpNumericValue(const char* dumpName,
const char* valueName,
diff --git a/chromium/skia/ext/skia_utils_base.cc b/chromium/skia/ext/skia_utils_base.cc
index dddb02d4680..5d9e9286fa1 100644
--- a/chromium/skia/ext/skia_utils_base.cc
+++ b/chromium/skia/ext/skia_utils_base.cc
@@ -8,25 +8,42 @@
#include "base/pickle.h"
#include "third_party/skia/include/core/SkData.h"
+#include "third_party/skia/include/core/SkImageDeserializer.h"
#include "third_party/skia/include/core/SkWriteBuffer.h"
+#include "third_party/skia/src/core/SkValidatingReadBuffer.h"
namespace skia {
namespace {
-class CodecDisallowingPixelSerializer : public SkPixelSerializer {
+class CodecDecodingPixelSerializer : public SkPixelSerializer {
public:
- CodecDisallowingPixelSerializer() = default;
- ~CodecDisallowingPixelSerializer() override = default;
+ CodecDecodingPixelSerializer() = default;
+ ~CodecDecodingPixelSerializer() override = default;
protected:
- bool onUseEncodedData(const void* data, size_t len) override {
- CHECK(false) << "We should not have codec backed image filters";
- return false;
- }
+ // Disallowing serializing the encoded data.
+ bool onUseEncodedData(const void* data, size_t len) override { return false; }
+ // Don't return any encoded data to ensure the decoded bitmap is serialized.
SkData* onEncode(const SkPixmap&) override { return nullptr; }
};
+class CodecDisallowingImageDeserializer : public SkImageDeserializer {
+ public:
+ ~CodecDisallowingImageDeserializer() override = default;
+
+ sk_sp<SkImage> makeFromData(SkData*, const SkIRect* subset) override {
+ LOG(ERROR) << "Encoded image rejected during SkFlattenable deserialization";
+ return nullptr;
+ }
+ sk_sp<SkImage> makeFromMemory(const void* data,
+ size_t length,
+ const SkIRect* subset) override {
+ LOG(ERROR) << "Encoded image rejected during SkFlattenable deserialization";
+ return nullptr;
+ }
+};
+
} // namespace
bool ReadSkString(base::PickleIterator* iter, SkString* str) {
@@ -98,7 +115,7 @@ void WriteSkFontStyle(base::Pickle* pickle, SkFontStyle style) {
sk_sp<SkData> ValidatingSerializeFlattenable(SkFlattenable* flattenable) {
SkBinaryWriteBuffer writer;
- writer.setPixelSerializer(sk_make_sp<CodecDisallowingPixelSerializer>());
+ writer.setPixelSerializer(sk_make_sp<CodecDecodingPixelSerializer>());
writer.writeFlattenable(flattenable);
size_t size = writer.bytesWritten();
auto data = SkData::MakeUninitialized(size);
@@ -106,4 +123,13 @@ sk_sp<SkData> ValidatingSerializeFlattenable(SkFlattenable* flattenable) {
return data;
}
+SkFlattenable* ValidatingDeserializeFlattenable(const void* data,
+ size_t size,
+ SkFlattenable::Type type) {
+ SkValidatingReadBuffer buffer(data, size);
+ CodecDisallowingImageDeserializer image_deserializer;
+ buffer.setImageDeserializer(&image_deserializer);
+ return buffer.readFlattenable(type);
+}
+
} // namespace skia
diff --git a/chromium/skia/ext/skia_utils_base.h b/chromium/skia/ext/skia_utils_base.h
index 5c6aa10035f..5e7db25bb29 100644
--- a/chromium/skia/ext/skia_utils_base.h
+++ b/chromium/skia/ext/skia_utils_base.h
@@ -5,6 +5,7 @@
#ifndef SKIA_EXT_SKIA_UTILS_BASE_H_
#define SKIA_EXT_SKIA_UTILS_BASE_H_
+#include "third_party/skia/include/core/SkFlattenable.h"
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
namespace base {
@@ -41,10 +42,17 @@ SK_API void WriteSkFontIdentity(
// Writes style into the request pickle.
SK_API void WriteSkFontStyle(base::Pickle* pickle, SkFontStyle style);
-// Serializes the SkFlattenable. This method should never be used with an
-// SkFlattenable containing encoded images.
+// Serializes the SkFlattenable. Any encoded images contained in the flattenable
+// will be decoded during serialization.
SK_API sk_sp<SkData> ValidatingSerializeFlattenable(SkFlattenable* flattenable);
+// Deserializes the SkFlattenable. This method must not be called with data
+// containing encoded images.
+SK_API SkFlattenable* ValidatingDeserializeFlattenable(
+ const void* data,
+ size_t size,
+ SkFlattenable::Type type);
+
} // namespace skia
#endif // SKIA_EXT_SKIA_UTILS_BASE_H_
diff --git a/chromium/skia/ext/skia_utils_base_unittest.cc b/chromium/skia/ext/skia_utils_base_unittest.cc
index a7fb8e0af53..ab6f3af2f67 100644
--- a/chromium/skia/ext/skia_utils_base_unittest.cc
+++ b/chromium/skia/ext/skia_utils_base_unittest.cc
@@ -6,44 +6,123 @@
#include "base/memory/ptr_util.h"
#include "base/test/gtest_util.h"
+#include "base/test/test_discardable_memory_allocator.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkFlattenableSerialization.h"
#include "third_party/skia/include/core/SkImageGenerator.h"
+#include "third_party/skia/include/core/SkPixelSerializer.h"
+#include "third_party/skia/include/core/SkWriteBuffer.h"
#include "third_party/skia/include/effects/SkImageSource.h"
#include "third_party/skia/include/effects/SkPaintImageFilter.h"
namespace skia {
namespace {
+// Raw data for a PNG file with 1x1 white pixels.
+const unsigned char kWhitePNG[] = {
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
+ 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
+ 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, 0x00, 0x00, 0x00,
+ 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
+ 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
+ 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x49,
+ 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x05,
+ 0xfe, 0x02, 0xfe, 0xdc, 0xcc, 0x59, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x49,
+ 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
+};
+
class FakeImageGenerator : public SkImageGenerator {
public:
FakeImageGenerator() : SkImageGenerator(SkImageInfo::MakeN32Premul(10, 10)) {}
- ~FakeImageGenerator() override = default;
+ ~FakeImageGenerator() override { EXPECT_TRUE(decoded_); }
SkData* onRefEncodedData() override {
// Use a generator that lets the caller encode it.
return SkData::MakeWithCString("evilimage").release();
}
- bool onGetPixels(const SkImageInfo&, void*, size_t, const Options&) override {
- NOTREACHED();
+ bool onGetPixels(const SkImageInfo& info,
+ void* pixels,
+ size_t,
+ const Options&) override {
+ decoded_ = true;
+ memset(pixels, 0, info.computeMinByteSize());
+ return true;
+ }
+
+ private:
+ bool decoded_ = false;
+};
+
+class PixelSerializer : public SkPixelSerializer {
+ public:
+ bool onUseEncodedData(const void* data, size_t len) override {
+ CHECK(false);
return false;
}
+
+ SkData* onEncode(const SkPixmap&) override {
+ EXPECT_TRUE(has_decoded_images_);
+ return nullptr;
+ }
+
+ bool has_decoded_images_ = false;
};
-#if GTEST_HAS_DEATH_TEST
-TEST(SkiaUtilsBaseTest, ImageSerializationFails) {
+TEST(SkiaUtilsBaseTest, ImageSerializationDecodesImage) {
+ base::TestDiscardableMemoryAllocator allocator;
+ base::DiscardableMemoryAllocator::SetInstance(&allocator);
+
auto image =
SkImage::MakeFromGenerator(base::MakeUnique<FakeImageGenerator>());
auto filter = SkImageSource::Make(image);
- EXPECT_DEATH(ValidatingSerializeFlattenable(filter.get()), "");
- SkPaint paint;
- paint.setShader(
- image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
- filter = SkPaintImageFilter::Make(paint);
- EXPECT_DEATH(ValidatingSerializeFlattenable(filter.get()), "");
+ // Serialize the filter. This decodes the image.
+ sk_sp<SkData> data = ValidatingSerializeFlattenable(filter.get());
+
+ // Deserialize.
+ auto deserialized_filter =
+ sk_sp<SkImageFilter>((SkImageFilter*)ValidatingDeserializeFlattenable(
+ data->data(), data->size(), SkImageFilter::GetFlattenableType()));
+
+ // Now serialize again to ensure that the deserialized filter did not have any
+ // encoded images. Serialization is the only way to deep inspect the filter.
+ SkBinaryWriteBuffer writer;
+ auto pixel_serializer = sk_make_sp<PixelSerializer>();
+ pixel_serializer->has_decoded_images_ = true;
+ writer.setPixelSerializer(pixel_serializer);
+ writer.writeFlattenable(deserialized_filter.get());
+ EXPECT_GT(writer.bytesWritten(), 0u);
+
+ base::DiscardableMemoryAllocator::SetInstance(nullptr);
+}
+
+TEST(SkiaUtilsBaseTest, DeserializationWithEncodedImagesFails) {
+ base::TestDiscardableMemoryAllocator allocator;
+ base::DiscardableMemoryAllocator::SetInstance(&allocator);
+
+ auto image = SkImage::MakeFromGenerator(SkImageGenerator::MakeFromEncoded(
+ SkData::MakeWithoutCopy(kWhitePNG, sizeof(kWhitePNG))));
+ auto filter = SkImageSource::Make(image);
+
+ // Serialize the filter using default serialization.
+ sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get()));
+
+ // Deserialize with images disabled.
+ auto deserialized_filter =
+ sk_sp<SkImageFilter>((SkImageFilter*)ValidatingDeserializeFlattenable(
+ data->data(), data->size(), SkImageFilter::GetFlattenableType()));
+
+ // Now serialize again to make sure that all encoded images were rejected
+ // during serialization.
+ SkBinaryWriteBuffer writer;
+ auto pixel_serializer = sk_make_sp<PixelSerializer>();
+ writer.setPixelSerializer(pixel_serializer);
+ writer.writeFlattenable(deserialized_filter.get());
+ EXPECT_GT(writer.bytesWritten(), 0u);
+
+ base::DiscardableMemoryAllocator::SetInstance(nullptr);
}
-#endif
} // namespace
} // namespace skia