summaryrefslogtreecommitdiff
path: root/chromium/skia
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-08-01 12:59:39 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:40:43 +0000
commit28b1110370900897ab652cb420c371fab8857ad4 (patch)
tree41b32127d23b0df4f2add2a27e12dc87bddb260e /chromium/skia
parent399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (diff)
downloadqtwebengine-chromium-28b1110370900897ab652cb420c371fab8857ad4.tar.gz
BASELINE: Update Chromium to 53.0.2785.41
Also adds a few extra files for extensions. Change-Id: Iccdd55d98660903331cf8b7b29188da781830af4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/skia')
-rw-r--r--chromium/skia/BUILD.gn240
-rw-r--r--chromium/skia/chromium_skia_defines.gypi1
-rw-r--r--chromium/skia/config/SkUserConfig.h11
-rw-r--r--chromium/skia/ext/SkTypeface_fake.cpp23
-rw-r--r--chromium/skia/ext/analysis_canvas_unittest.cc6
-rw-r--r--chromium/skia/ext/benchmarking_canvas.cc12
-rw-r--r--chromium/skia/ext/bitmap_platform_device_win.cc12
-rw-r--r--chromium/skia/ext/image_operations.cc17
-rw-r--r--chromium/skia/ext/platform_surface.h4
-rw-r--r--chromium/skia/ext/refptr.h171
-rw-r--r--chromium/skia/ext/refptr_unittest.cc244
-rw-r--r--chromium/skia/ext/skia_memory_dump_provider.cc16
-rw-r--r--chromium/skia/ext/skia_memory_dump_provider_unittest.cc4
-rw-r--r--chromium/skia/ext/skia_utils_mac.h14
-rw-r--r--chromium/skia/ext/skia_utils_mac.mm105
-rw-r--r--chromium/skia/ext/skia_utils_mac_unittest.mm33
-rw-r--r--chromium/skia/public/BUILD.gn20
-rw-r--r--chromium/skia/public/interfaces/BUILD.gn12
-rw-r--r--chromium/skia/public/interfaces/OWNERS5
-rw-r--r--chromium/skia/public/interfaces/bitmap.mojom3
-rw-r--r--chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.cc202
-rw-r--r--chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.h35
-rw-r--r--chromium/skia/public/interfaces/image_filter.mojom10
-rw-r--r--chromium/skia/public/interfaces/image_filter.typemap11
-rw-r--r--chromium/skia/public/interfaces/image_filter_struct_traits.cc50
-rw-r--r--chromium/skia/public/interfaces/image_filter_struct_traits.h56
-rw-r--r--chromium/skia/public/interfaces/skbitmap.typemap11
-rw-r--r--chromium/skia/public/interfaces/typemaps.gni8
-rw-r--r--chromium/skia/public/type_converters.cc141
-rw-r--r--chromium/skia/public/type_converters.h26
-rw-r--r--chromium/skia/skia.gyp26
-rw-r--r--chromium/skia/skia_common.gypi5
-rw-r--r--chromium/skia/skia_library.gypi3
-rw-r--r--chromium/skia/skia_tests.gyp1
34 files changed, 630 insertions, 908 deletions
diff --git a/chromium/skia/BUILD.gn b/chromium/skia/BUILD.gn
index a2fd88aa2e0..eb6628cc3a6 100644
--- a/chromium/skia/BUILD.gn
+++ b/chromium/skia/BUILD.gn
@@ -15,6 +15,19 @@ if (current_cpu == "mipsel" || current_cpu == "mips64el") {
skia_support_gpu = !is_ios
skia_support_pdf = !is_ios && (enable_basic_printing || enable_print_preview)
+# When building Chrome for iOS with GYP, the target cpu is not known during
+# the invocation of gyp. This cause the iOS build to use non-optimised skia.
+# Replicate this with GN to avoid introducing regression as recommended by
+# the OWNERS of skia.
+
+declare_args() {
+ skia_whitelist_serialized_typefaces = false
+
+ # TODO(crbug.com/607933): Once GYP is no longer supported, port iOS to use
+ # optimised skia.
+ skia_build_no_opts = is_ios
+}
+
# The list of Skia defines that are to be set for chromium.
gypi_chromium_skia_defines =
exec_script("//build/gypi_to_gn.py",
@@ -141,6 +154,10 @@ config("skia_config") {
defines += []
+ if (skia_build_no_opts) {
+ defines += [ "SK_BUILD_NO_OPTS" ]
+ }
+
if (is_component_build) {
defines += [
"SKIA_DLL",
@@ -172,6 +189,10 @@ config("skia_config") {
if (is_win) {
defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
}
+
+ if (skia_whitelist_serialized_typefaces) {
+ defines += [ "SK_WHITELIST_SERIALIZED_TYPEFACES" ]
+ }
}
# Internal-facing config for Skia library code.
@@ -204,7 +225,7 @@ config("skia_library_config") {
defines += [ "SKIA_IMPLEMENTATION=1" ]
}
- if (current_cpu == "arm") {
+ if (current_cpu == "arm" && !skia_build_no_opts) {
if (arm_use_neon) {
defines += [ "SK_ARM_HAS_NEON" ]
} else if (arm_optionally_use_neon) {
@@ -501,6 +522,7 @@ component("skia") {
if (is_mac) {
libs = [
"AppKit.framework",
+ "ApplicationServices.framework", # Temporary hack around https://crbug.com/620127. Remove after https://crbug.com/622481 is fixed.
"CoreFoundation.framework",
"CoreGraphics.framework",
"CoreText.framework",
@@ -518,94 +540,97 @@ component("skia") {
]
set_sources_assignment_filter(sources_assignment_filter)
- # To disable warning "CGContextSelectFont' is deprecated"
+ # SkFontHost_mac.cpp uses API deprecated in iOS 7, crbug.com/408571
cflags = [ "-Wno-deprecated-declarations" ]
}
}
# Separated out so it can be compiled with different flags for SSE.
-if (current_cpu == "x86" || current_cpu == "x64") {
- source_set("skia_opts_sse3") {
- sources = gypi_skia_opts.ssse3_sources
- if (!is_win || is_clang) {
- cflags = [ "-mssse3" ]
- }
- if (is_win) {
- defines = [ "SK_CPU_SSE_LEVEL=31" ]
- }
- visibility = [ ":skia_opts" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":skia_config",
- ":skia_library_config",
- "//build/config/compiler:no_chromium_code",
- ]
- }
- source_set("skia_opts_sse41") {
- sources = gypi_skia_opts.sse41_sources
- if (!is_win || is_clang) {
- cflags = [ "-msse4.1" ]
- }
- if (is_win) {
- defines = [ "SK_CPU_SSE_LEVEL=41" ]
- }
- visibility = [ ":skia_opts" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":skia_config",
- ":skia_library_config",
- "//build/config/compiler:no_chromium_code",
- ]
- }
- source_set("skia_opts_sse42") {
- sources = gypi_skia_opts.sse42_sources
- if (!is_win || is_clang) {
- cflags = [ "-msse4.2" ]
- }
- if (is_win) {
- defines = [ "SK_CPU_SSE_LEVEL=42" ]
+if (!skia_build_no_opts) {
+ if (current_cpu == "x86" || current_cpu == "x64") {
+ source_set("skia_opts_sse3") {
+ sources = gypi_skia_opts.ssse3_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-mssse3" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=31" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
}
- visibility = [ ":skia_opts" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":skia_config",
- ":skia_library_config",
- "//build/config/compiler:no_chromium_code",
- ]
- }
- source_set("skia_opts_avx") {
- sources = gypi_skia_opts.avx_sources
- if (!is_win) {
- cflags = [ "-mavx" ]
+ source_set("skia_opts_sse41") {
+ sources = gypi_skia_opts.sse41_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-msse4.1" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=41" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
}
- if (is_win) {
- cflags = [ "/arch:AVX" ]
+ source_set("skia_opts_sse42") {
+ sources = gypi_skia_opts.sse42_sources
+ if (!is_win || is_clang) {
+ cflags = [ "-msse4.2" ]
+ }
+ if (is_win) {
+ defines = [ "SK_CPU_SSE_LEVEL=42" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
}
- visibility = [ ":skia_opts" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":skia_config",
- ":skia_library_config",
- "//build/config/compiler:no_chromium_code",
- ]
- }
- source_set("skia_opts_avx2") {
- sources = gypi_skia_opts.avx2_sources
- if (!is_win) {
- cflags = [ "-mavx2" ]
+ source_set("skia_opts_avx") {
+ sources = gypi_skia_opts.avx_sources
+ if (!is_win) {
+ cflags = [ "-mavx" ]
+ }
+ if (is_win) {
+ cflags = [ "/arch:AVX" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
}
- if (is_win) {
- cflags = [ "/arch:AVX2" ]
+ source_set("skia_opts_avx2") {
+ sources = gypi_skia_opts.avx2_sources
+ if (!is_win) {
+ cflags = [ "-mavx2" ]
+ }
+ if (is_win) {
+ cflags = [ "/arch:AVX2" ]
+ }
+ visibility = [ ":skia_opts" ]
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [
+ ":skia_config",
+ ":skia_library_config",
+ "//build/config/compiler:no_chromium_code",
+ ]
}
- visibility = [ ":skia_opts" ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [
- ":skia_config",
- ":skia_library_config",
- "//build/config/compiler:no_chromium_code",
- ]
}
}
+
source_set("skia_opts") {
cflags = []
defines = []
@@ -614,7 +639,9 @@ source_set("skia_opts") {
"//base",
]
- if (current_cpu == "x86" || current_cpu == "x64") {
+ if (skia_build_no_opts) {
+ sources = gypi_skia_opts.none_sources
+ } else if (current_cpu == "x86" || current_cpu == "x64") {
sources = gypi_skia_opts.sse2_sources
deps += [
":skia_opts_avx",
@@ -683,7 +710,6 @@ test("skia_unittests") {
"ext/image_operations_unittest.cc",
"ext/platform_canvas_unittest.cc",
"ext/recursive_gaussian_convolution_unittest.cc",
- "ext/refptr_unittest.cc",
"ext/skia_memory_dump_provider_unittest.cc",
"ext/skia_utils_ios_unittest.mm",
"ext/skia_utils_mac_unittest.mm",
@@ -696,39 +722,49 @@ test("skia_unittests") {
deps = [
":skia",
"//base",
- "//base/test:run_all_unittests",
+ "//mojo/edk/test:run_all_unittests",
"//testing/gtest",
"//ui/gfx",
"//ui/gfx/geometry",
]
if (!is_ios) {
- deps += [ "//cc:test_support" ] # TODO: Fix this test to not depend on cc.
+ sources += [ "public/interfaces/test/struct_traits_unittest.cc" ]
+ deps += [
+ # TODO: Fix this test to not depend on cc.
+ "//cc:test_support",
+ "//mojo/public/cpp/bindings",
+ "//skia/public/interfaces:test_interfaces",
+ ]
}
}
-executable("image_operations_bench") {
- sources = [
- "ext/image_operations_bench.cc",
- ]
+if (!is_ios) {
+ executable("image_operations_bench") {
+ sources = [
+ "ext/image_operations_bench.cc",
+ ]
- deps = [
- ":skia",
- "//base",
- "//build/config/sanitizers:deps",
- ]
-}
+ deps = [
+ ":skia",
+ "//base",
+ "//build/config/sanitizers:deps",
+ "//build/win:default_exe_manifest",
+ ]
+ }
-executable("filter_fuzz_stub") {
- testonly = true
- sources = [
- "tools/filter_fuzz_stub/filter_fuzz_stub.cc",
- ]
+ executable("filter_fuzz_stub") {
+ testonly = true
+ sources = [
+ "tools/filter_fuzz_stub/filter_fuzz_stub.cc",
+ ]
- deps = [
- ":skia",
- "//base",
- "//base/test:test_support",
- "//build/config/sanitizers:deps",
- ]
+ deps = [
+ ":skia",
+ "//base",
+ "//base/test:test_support",
+ "//build/config/sanitizers:deps",
+ "//build/win:default_exe_manifest",
+ ]
+ }
}
diff --git a/chromium/skia/chromium_skia_defines.gypi b/chromium/skia/chromium_skia_defines.gypi
index 2d7b97f7c5c..752e83a31ac 100644
--- a/chromium/skia/chromium_skia_defines.gypi
+++ b/chromium/skia/chromium_skia_defines.gypi
@@ -19,6 +19,7 @@
# made to remove these defines as soon as practical. This is in contrast to
# defines in SkUserConfig.h which are normally more permanent.
'chromium_skia_defines': [
+ 'SK_IGNORE_DW_GRAY_FIX'
],
},
}
diff --git a/chromium/skia/config/SkUserConfig.h b/chromium/skia/config/SkUserConfig.h
index 246bb56f08e..613003e3878 100644
--- a/chromium/skia/config/SkUserConfig.h
+++ b/chromium/skia/config/SkUserConfig.h
@@ -226,14 +226,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
# define SK_IGNORE_GPU_DITHER
#endif
-#ifndef SK_SUPPORT_LEGACY_IMAGEFACTORY
-# define SK_SUPPORT_LEGACY_IMAGEFACTORY
-#endif
-
-#ifndef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
-# define SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
-#endif
-
#ifndef SK_SUPPORT_LEGACY_EVAL_CUBIC
# define SK_SUPPORT_LEGACY_EVAL_CUBIC
#endif
@@ -242,9 +234,6 @@ SK_API void SkDebugf_FileLine(const char* file, int line, bool fatal,
# define SK_SUPPORT_LEGACY_COMPUTESAVELAYER_FLAG
#endif
-#ifndef SK_SUPPORT_LEGACY_TYPEFACE_PTR
-# define SK_SUPPORT_LEGACY_TYPEFACE_PTR
-#endif
///////////////////////// Imported from BUILD.gn and skia_common.gypi
/* In some places Skia can use static initializers for global initialization,
diff --git a/chromium/skia/ext/SkTypeface_fake.cpp b/chromium/skia/ext/SkTypeface_fake.cpp
deleted file mode 100644
index 954b304a5f6..00000000000
--- a/chromium/skia/ext/SkTypeface_fake.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2009 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 <stdint.h>
-
-#include "SkTypeface.h"
-
-// ===== Begin Chrome-specific definitions =====
-
-uint32_t SkTypeface::UniqueID(const SkTypeface* face)
-{
- return 0;
-}
-
-void SkTypeface::serialize(SkWStream* stream) const {
-}
-
-SkTypeface* SkTypeface::Deserialize(SkStream* stream) {
- return NULL;
-}
-
-// ===== End Chrome-specific definitions =====
diff --git a/chromium/skia/ext/analysis_canvas_unittest.cc b/chromium/skia/ext/analysis_canvas_unittest.cc
index 413e49399b2..27f2bc5f0ac 100644
--- a/chromium/skia/ext/analysis_canvas_unittest.cc
+++ b/chromium/skia/ext/analysis_canvas_unittest.cc
@@ -4,10 +4,10 @@
#include "base/compiler_specific.h"
#include "skia/ext/analysis_canvas.h"
-#include "skia/ext/refptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
+#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/effects/SkOffsetImageFilter.h"
@@ -183,9 +183,7 @@ TEST(AnalysisCanvasTest, FilterPaint) {
skia::AnalysisCanvas canvas(255, 255);
SkPaint paint;
- skia::RefPtr<SkImageFilter> filter =
- skia::AdoptRef(SkOffsetImageFilter::Create(10, 10));
- paint.setImageFilter(filter.get());
+ paint.setImageFilter(SkOffsetImageFilter::Make(10, 10, nullptr));
canvas.drawRect(SkRect::MakeWH(255, 255), paint);
SkColor outputColor;
diff --git a/chromium/skia/ext/benchmarking_canvas.cc b/chromium/skia/ext/benchmarking_canvas.cc
index cccedd0ce37..fb9845fe85e 100644
--- a/chromium/skia/ext/benchmarking_canvas.cc
+++ b/chromium/skia/ext/benchmarking_canvas.cc
@@ -109,7 +109,7 @@ WARN_UNUSED_RESULT
std::unique_ptr<base::Value> AsValue(const SkMatrix& matrix) {
std::unique_ptr<base::ListValue> val(new base::ListValue());
for (int i = 0; i < 9; ++i)
- val->Append(AsValue(matrix[i]).release()); // no scoped_ptr-aware Append() variant
+ val->Append(AsValue(matrix[i])); // no scoped_ptr-aware Append() variant
return std::move(val);
}
@@ -170,7 +170,7 @@ std::unique_ptr<base::Value> AsValue(const SkColorFilter& filter) {
if (filter.asColorMatrix(color_matrix)) {
std::unique_ptr<base::ListValue> color_matrix_val(new base::ListValue());
for (unsigned i = 0; i < 20; ++i)
- color_matrix_val->Append(AsValue(color_matrix[i]).release());
+ color_matrix_val->Append(AsValue(color_matrix[i]));
val->Set("color_matrix", std::move(color_matrix_val));
}
@@ -380,14 +380,14 @@ std::unique_ptr<base::Value> AsValue(const SkPath& path) {
std::unique_ptr<base::ListValue> pts_val(new base::ListValue());
for (int i = 0; i < gPtsPerVerb[verb]; ++i)
- pts_val->Append(AsValue(points[i + gPtOffsetPerVerb[verb]]).release());
+ pts_val->Append(AsValue(points[i + gPtOffsetPerVerb[verb]]));
verb_val->Set(gVerbStrings[verb], std::move(pts_val));
if (SkPath::kConic_Verb == verb)
verb_val->Set("weight", AsValue(iter.conicWeight()));
- verbs_val->Append(verb_val.release());
+ verbs_val->Append(std::move(verb_val));
}
val->Set("verbs", std::move(verbs_val));
@@ -400,7 +400,7 @@ WARN_UNUSED_RESULT std::unique_ptr<base::Value> AsListValue(const T array[],
std::unique_ptr<base::ListValue> val(new base::ListValue());
for (size_t i = 0; i < count; ++i)
- val->Append(AsValue(array[i]).release());
+ val->Append(AsValue(array[i]));
return std::move(val);
}
@@ -492,7 +492,7 @@ public:
std::unique_ptr<base::DictionaryValue> param(new base::DictionaryValue());
param->Set(name, std::move(value));
- op_params_->Append(param.release());
+ op_params_->Append(std::move(param));
}
const SkPaint* paint() const { return &filtered_paint_; }
diff --git a/chromium/skia/ext/bitmap_platform_device_win.cc b/chromium/skia/ext/bitmap_platform_device_win.cc
index 86784314517..f440edabbce 100644
--- a/chromium/skia/ext/bitmap_platform_device_win.cc
+++ b/chromium/skia/ext/bitmap_platform_device_win.cc
@@ -168,19 +168,25 @@ BitmapPlatformDevice* BitmapPlatformDevice::Create(
// shared memory as the bitmap.
if (base::win::IsUser32AndGdi32Available()) {
hbitmap = CreateHBitmap(width, height, is_opaque, shared_section, &data);
- if (!hbitmap)
+ if (!hbitmap) {
+ LOG(ERROR) << "CreateHBitmap failed";
return NULL;
+ }
} else {
DCHECK(shared_section != NULL);
data = MapViewOfFile(shared_section, FILE_MAP_WRITE, 0, 0,
PlatformCanvasStrideForWidth(width) * height);
- if (!data)
+ if (!data) {
+ LOG(ERROR) << "MapViewOfFile failed";
return NULL;
+ }
}
SkBitmap bitmap;
- if (!InstallHBitmapPixels(&bitmap, width, height, is_opaque, data, hbitmap))
+ if (!InstallHBitmapPixels(&bitmap, width, height, is_opaque, data, hbitmap)) {
+ LOG(ERROR) << "InstallHBitmapPixels failed";
return NULL;
+ }
if (do_clear)
bitmap.eraseColor(0);
diff --git a/chromium/skia/ext/image_operations.cc b/chromium/skia/ext/image_operations.cc
index 985787bae38..26bd44e5933 100644
--- a/chromium/skia/ext/image_operations.cc
+++ b/chromium/skia/ext/image_operations.cc
@@ -160,14 +160,6 @@ class ResizeFilter {
ImageOperations::ResizeMethod method_;
- // Size of the filter support on one side only in the destination space.
- // See GetFilterSupport.
- float x_filter_support_;
- float y_filter_support_;
-
- // Subset of scaled destination bitmap to compute.
- SkIRect out_bounds_;
-
ConvolutionFilter1D x_filter_;
ConvolutionFilter1D y_filter_;
@@ -175,11 +167,12 @@ class ResizeFilter {
};
ResizeFilter::ResizeFilter(ImageOperations::ResizeMethod method,
- int src_full_width, int src_full_height,
- int dest_width, int dest_height,
+ int src_full_width,
+ int src_full_height,
+ int dest_width,
+ int dest_height,
const SkIRect& dest_subset)
- : method_(method),
- out_bounds_(dest_subset) {
+ : method_(method) {
// method_ will only ever refer to an "algorithm method".
SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) &&
(method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD));
diff --git a/chromium/skia/ext/platform_surface.h b/chromium/skia/ext/platform_surface.h
index b0d5173c40f..793bf649b64 100644
--- a/chromium/skia/ext/platform_surface.h
+++ b/chromium/skia/ext/platform_surface.h
@@ -10,7 +10,9 @@
#include "third_party/skia/include/core/SkTypes.h"
#include "third_party/skia/include/core/SkRect.h"
-#if defined(USE_CAIRO)
+#if defined(OS_WIN)
+#include <windows.h>
+#elif defined(USE_CAIRO)
typedef struct _cairo cairo_t;
typedef struct _cairo_rectangle cairo_rectangle_t;
#elif defined(OS_MACOSX)
diff --git a/chromium/skia/ext/refptr.h b/chromium/skia/ext/refptr.h
deleted file mode 100644
index a1860334a4f..00000000000
--- a/chromium/skia/ext/refptr.h
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright 2012 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 SKIA_EXT_REFPTR_H_
-#define SKIA_EXT_REFPTR_H_
-
-#include <algorithm>
-#include <cstddef>
-
-#include "third_party/skia/include/core/SkRefCnt.h"
-
-namespace skia {
-
-// When creating/receiving a ref-counted pointer from Skia, wrap that pointer in
-// this class to avoid dealing with the ref-counting and prevent leaks/crashes
-// due to ref-counting bugs.
-//
-// Example of creating a new SkShader* and setting it on a SkPaint:
-// skia::RefPtr<SkShader> shader = skia::AdoptRef(SkGradientShader::Create());
-// paint.setShader(shader.get());
-//
-// When passing around a ref-counted pointer to methods outside of Skia, always
-// pass around the skia::RefPtr instead of the raw pointer. An example method
-// that takes a SkShader* parameter and saves the SkShader* in the class.
-// void AMethodThatSavesAShader(const skia::RefPtr<SkShader>& shader) {
-// member_refptr_ = shader;
-// }
-// skia::RefPtr<SkShader> member_refptr_;
-//
-// When returning a ref-counted pointer, also return the skia::RefPtr instead.
-// An example method that creates an SkShader* and returns it:
-// skia::RefPtr<SkShader> MakeAShader() {
-// return skia::AdoptRef(SkGradientShader::Create());
-// }
-//
-// To take a scoped reference to an object whose references are all owned
-// by other objects (i.e. does not have one that needs to be adopted) use the
-// skia::SharePtr helper:
-//
-// skia::RefPtr<SkShader> shader = skia::SharePtr(paint.getShader());
-//
-// To pass a reference while clearing the pointer (without changing the ref
-// count):
-//
-// skia::RefPtr<SkShader> shader = ...;
-// UseThisShader(std::move(shader));
-//
-// Never call ref() or unref() on the underlying ref-counted pointer. If you
-// AdoptRef() the raw pointer immediately into a skia::RefPtr and always work
-// with skia::RefPtr instances instead, the ref-counting will be taken care of
-// for you.
-template<typename T>
-class RefPtr {
- public:
- using element_type = T;
-
- RefPtr() : ptr_(nullptr) {}
-
- RefPtr(std::nullptr_t) : ptr_(nullptr) {}
-
- // Copy constructor.
- RefPtr(const RefPtr& other)
- : ptr_(other.get()) {
- SkSafeRef(ptr_);
- }
-
- // Copy conversion constructor.
- template<typename U>
- RefPtr(const RefPtr<U>& other)
- : ptr_(other.get()) {
- SkSafeRef(ptr_);
- }
-
- // Move constructor. This is required in addition to the conversion
- // constructor below in order for clang to warn about pessimizing moves.
- RefPtr(RefPtr&& other) : ptr_(other.get()) { other.ptr_ = nullptr; }
-
- // Move conversion constructor.
- template <typename U>
- RefPtr(RefPtr<U>&& other)
- : ptr_(other.get()) {
- other.ptr_ = nullptr;
- }
-
- ~RefPtr() {
- clear();
- }
-
- RefPtr& operator=(std::nullptr_t) {
- clear();
- return *this;
- }
-
- RefPtr& operator=(const RefPtr& other) {
- SkRefCnt_SafeAssign(ptr_, other.get());
- return *this;
- }
-
- template<typename U>
- RefPtr& operator=(const RefPtr<U>& other) {
- SkRefCnt_SafeAssign(ptr_, other.get());
- return *this;
- }
-
- template <typename U>
- RefPtr& operator=(RefPtr<U>&& other) {
- RefPtr<T> temp(std::move(other));
- std::swap(ptr_, temp.ptr_);
- return *this;
- }
-
- void clear() {
- T* to_unref = ptr_;
- ptr_ = nullptr;
- SkSafeUnref(to_unref);
- }
-
- T* get() const { return ptr_; }
- T& operator*() const { return *ptr_; }
- T* operator->() const { return ptr_; }
-
- typedef T* RefPtr::*unspecified_bool_type;
- operator unspecified_bool_type() const {
- return ptr_ ? &RefPtr::ptr_ : nullptr;
- }
-
- private:
- T* ptr_;
-
- // This function cannot be public because Skia starts its ref-counted
- // objects at refcnt=1. This makes it impossible to differentiate
- // between a newly created object (that doesn't need to be ref'd) or an
- // already existing object with one owner (that does need to be ref'd so that
- // this RefPtr can also manage its lifetime).
- explicit RefPtr(T* ptr) : ptr_(ptr) {}
-
- template<typename U>
- friend RefPtr<U> AdoptRef(U* ptr);
-
- template<typename U>
- friend RefPtr<U> AdoptRef(sk_sp<U>&&);
-
- template<typename U>
- friend RefPtr<U> SharePtr(U* ptr);
-
- template<typename U>
- friend RefPtr<U> SharePtr(sk_sp<U>);
-
- template <typename U>
- friend class RefPtr;
-};
-
-// For objects that have an unowned reference (such as newly created objects).
-template<typename T>
-RefPtr<T> AdoptRef(T* ptr) { return RefPtr<T>(ptr); }
-
-template<typename T>
-RefPtr<T> AdoptRef(sk_sp<T>&& sp) { return RefPtr<T>(sp.release()); }
-
-// For objects that are already owned. This doesn't take ownership of existing
-// references and adds a new one.
-template<typename T>
-RefPtr<T> SharePtr(T* ptr) { return RefPtr<T>(SkSafeRef(ptr)); }
-
-template<typename T>
-RefPtr<T> SharePtr(sk_sp<T> sp) { return RefPtr<T>(sp.release()); }
-
-} // namespace skia
-
-#endif // SKIA_EXT_REFPTR_H_
diff --git a/chromium/skia/ext/refptr_unittest.cc b/chromium/skia/ext/refptr_unittest.cc
deleted file mode 100644
index cd25318ad51..00000000000
--- a/chromium/skia/ext/refptr_unittest.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-// Copyright 2012 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 "skia/ext/refptr.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace skia {
-namespace {
-
-TEST(RefPtrTest, ReferenceCounting) {
- SkRefCnt* ref = new SkRefCnt();
- EXPECT_TRUE(ref->unique());
-
- {
- // Adopt the reference from the caller on creation.
- RefPtr<SkRefCnt> refptr1 = AdoptRef(ref);
- EXPECT_TRUE(ref->unique());
- EXPECT_TRUE(refptr1->unique());
-
- EXPECT_EQ(ref, &*refptr1);
- EXPECT_EQ(ref, refptr1.get());
-
- {
- // Take a second reference for the second instance.
- RefPtr<SkRefCnt> refptr2(refptr1);
- EXPECT_FALSE(ref->unique());
-
- RefPtr<SkRefCnt> refptr3;
- EXPECT_FALSE(refptr3);
-
- // Take a third reference for the third instance.
- refptr3 = refptr1;
- EXPECT_FALSE(ref->unique());
-
- // Same object, so should have the same refcount.
- refptr2 = refptr3;
- EXPECT_FALSE(ref->unique());
-
- // Drop the object from refptr2, so it should lose its reference.
- EXPECT_TRUE(refptr2);
- refptr2.clear();
- EXPECT_FALSE(ref->unique());
-
- EXPECT_FALSE(refptr2);
- EXPECT_EQ(nullptr, refptr2.get());
-
- EXPECT_TRUE(refptr3);
- EXPECT_FALSE(refptr3->unique());
- EXPECT_EQ(ref, &*refptr3);
- EXPECT_EQ(ref, refptr3.get());
- }
-
- // Drop a reference when the third object is destroyed.
- EXPECT_TRUE(ref->unique());
- }
-}
-
-TEST(RefPtrTest, Construct) {
- SkRefCnt* ref = new SkRefCnt();
- EXPECT_TRUE(ref->unique());
-
- // Adopt the reference from the caller on creation.
- RefPtr<SkRefCnt> refptr1(AdoptRef(ref));
- EXPECT_TRUE(ref->unique());
- EXPECT_TRUE(refptr1->unique());
-
- EXPECT_EQ(ref, &*refptr1);
- EXPECT_EQ(ref, refptr1.get());
-
- RefPtr<SkRefCnt> refptr2(refptr1);
- EXPECT_FALSE(ref->unique());
-}
-
-TEST(RefPtrTest, DeclareAndAssign) {
- SkRefCnt* ref = new SkRefCnt();
- EXPECT_TRUE(ref->unique());
-
- // Adopt the reference from the caller on creation.
- RefPtr<SkRefCnt> refptr1 = AdoptRef(ref);
- EXPECT_TRUE(ref->unique());
- EXPECT_TRUE(refptr1->unique());
-
- EXPECT_EQ(ref, &*refptr1);
- EXPECT_EQ(ref, refptr1.get());
-
- RefPtr<SkRefCnt> refptr2 = refptr1;
- EXPECT_FALSE(ref->unique());
-}
-
-TEST(RefPtrTest, Assign) {
- SkRefCnt* ref = new SkRefCnt();
- EXPECT_TRUE(ref->unique());
-
- // Adopt the reference from the caller on creation.
- RefPtr<SkRefCnt> refptr1;
- refptr1 = AdoptRef(ref);
- EXPECT_TRUE(ref->unique());
- EXPECT_TRUE(refptr1->unique());
-
- EXPECT_EQ(ref, &*refptr1);
- EXPECT_EQ(ref, refptr1.get());
-
- RefPtr<SkRefCnt> refptr2;
- refptr2 = refptr1;
- EXPECT_FALSE(ref->unique());
-}
-
-class Subclass : public SkRefCnt {};
-
-TEST(RefPtrTest, Upcast) {
- RefPtr<Subclass> child = AdoptRef(new Subclass());
- EXPECT_TRUE(child->unique());
-
- RefPtr<SkRefCnt> parent = child;
- EXPECT_TRUE(child);
- EXPECT_TRUE(parent);
-
- EXPECT_FALSE(child->unique());
- EXPECT_FALSE(parent->unique());
-}
-
-// Counts the number of ref/unref operations (which require atomic operations)
-// that are done.
-class RefCountCounter : public SkRefCnt {
- public:
- void ref() const {
- ref_count_changes_++;
- SkRefCnt::ref();
- }
- void unref() const {
- ref_count_changes_++;
- SkRefCnt::unref();
- }
- int ref_count_changes() const { return ref_count_changes_; }
- void ResetRefCountChanges() { ref_count_changes_ = 0; }
-
- private:
- mutable int ref_count_changes_ = 0;
-};
-
-TEST(RefPtrTest, ConstructionFromTemporary) {
- // No ref count changes to move temporary into a local.
- RefPtr<RefCountCounter> object = skia::AdoptRef(new RefCountCounter);
- EXPECT_EQ(0, object->ref_count_changes());
-
- // Only one change to share the pointer.
- object->ResetRefCountChanges();
- RefPtr<RefCountCounter> shared = skia::SharePtr(object.get());
- EXPECT_EQ(1, object->ref_count_changes());
-
- // Two ref count changes for the extra ref when passed as an argument, but no
- // more.
- object->ResetRefCountChanges();
- auto do_nothing = [](RefPtr<RefCountCounter>) {};
- do_nothing(object);
- EXPECT_EQ(2, object->ref_count_changes());
-
- // No ref count changes when passing a newly adopted ref as an argument.
- auto lambda = [](RefPtr<RefCountCounter> arg) {
- EXPECT_EQ(0, arg->ref_count_changes());
- };
- lambda(skia::AdoptRef(new RefCountCounter));
-}
-
-TEST(RefPtrTest, AssignmentFromTemporary) {
- // No ref count changes to move temporary into a local.
- RefPtr<RefCountCounter> object;
- object = skia::AdoptRef(new RefCountCounter);
- EXPECT_EQ(0, object->ref_count_changes());
-
- // Only one change to share the pointer.
- object->ResetRefCountChanges();
- RefPtr<RefCountCounter> shared;
- shared = skia::SharePtr(object.get());
- EXPECT_EQ(1, object->ref_count_changes());
-}
-
-TEST(RefPtrTest, PassIntoArguments) {
- // No ref count changes when passing an argument with Pass().
- RefPtr<RefCountCounter> object = skia::AdoptRef(new RefCountCounter);
- RefPtr<RefCountCounter> object2 = std::move(object);
- auto lambda = [](RefPtr<RefCountCounter> arg) {
- EXPECT_EQ(0, arg->ref_count_changes());
- };
- lambda(std::move(object2));
-}
-
-class DestructionNotifier : public SkRefCnt {
- public:
- DestructionNotifier(bool* flag) : flag_(flag) {}
- ~DestructionNotifier() override { *flag_ = true; }
-
- private:
- bool* flag_;
-};
-
-TEST(RefPtrTest, Nullptr) {
- RefPtr<SkRefCnt> null(nullptr);
- EXPECT_FALSE(null);
-
- bool is_destroyed = false;
- RefPtr<DestructionNotifier> destroy_me =
- skia::AdoptRef(new DestructionNotifier(&is_destroyed));
- destroy_me = nullptr;
- EXPECT_TRUE(is_destroyed);
- EXPECT_FALSE(destroy_me);
-
- // Check that returning nullptr from a function correctly causes an implicit
- // conversion.
- auto lambda = []() -> RefPtr<SkRefCnt> { return nullptr; };
- RefPtr<SkRefCnt> returned = lambda();
- EXPECT_FALSE(returned);
-}
-
-TEST(RefPtrTest, SkSP) {
- sk_sp<RefCountCounter> sp = sk_make_sp<RefCountCounter>();
- EXPECT_EQ(0, sp->ref_count_changes());
-
- RefPtr<RefCountCounter> ref = skia::SharePtr(sp);
- EXPECT_FALSE(ref->unique());
- EXPECT_EQ(1, ref->ref_count_changes());
-
- sp = sk_make_sp<RefCountCounter>();
- EXPECT_TRUE(ref->unique());
- EXPECT_EQ(2, ref->ref_count_changes());
-
- ref = skia::SharePtr(std::move(sp));
- EXPECT_TRUE(ref->unique());
- EXPECT_EQ(0, ref->ref_count_changes());
-
- sp = sk_make_sp<RefCountCounter>();
- ref = skia::AdoptRef(std::move(sp));
- EXPECT_TRUE(ref->unique());
- EXPECT_EQ(0, ref->ref_count_changes());
-
- ref = skia::AdoptRef(sk_make_sp<RefCountCounter>());
- EXPECT_TRUE(ref->unique());
- EXPECT_EQ(0, ref->ref_count_changes());
-}
-
-} // namespace
-} // namespace skia
diff --git a/chromium/skia/ext/skia_memory_dump_provider.cc b/chromium/skia/ext/skia_memory_dump_provider.cc
index e0767526bea..c53cf7e62da 100644
--- a/chromium/skia/ext/skia_memory_dump_provider.cc
+++ b/chromium/skia/ext/skia_memory_dump_provider.cc
@@ -26,6 +26,22 @@ SkiaMemoryDumpProvider::~SkiaMemoryDumpProvider() {}
bool SkiaMemoryDumpProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* process_memory_dump) {
+ if (args.level_of_detail ==
+ base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) {
+ auto glyph_cache_dump =
+ process_memory_dump->CreateAllocatorDump("skia/sk_glyph_cache");
+ glyph_cache_dump->AddScalar(
+ base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ SkGraphics::GetFontCacheUsed());
+ auto resource_cache_dump =
+ process_memory_dump->CreateAllocatorDump("skia/sk_resource_cache");
+ resource_cache_dump->AddScalar(
+ base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ SkGraphics::GetResourceCacheTotalBytesUsed());
+ return true;
+ }
SkiaTraceMemoryDumpImpl skia_dumper(args.level_of_detail,
process_memory_dump);
SkGraphics::DumpMemoryStatistics(&skia_dumper);
diff --git a/chromium/skia/ext/skia_memory_dump_provider_unittest.cc b/chromium/skia/ext/skia_memory_dump_provider_unittest.cc
index a12e526e05c..85b83560282 100644
--- a/chromium/skia/ext/skia_memory_dump_provider_unittest.cc
+++ b/chromium/skia/ext/skia_memory_dump_provider_unittest.cc
@@ -13,10 +13,10 @@ namespace skia {
// Tests if the skia dump provider dumps without crashing.
TEST(SkiaMemoryDumpProviderTest, OnMemoryDump) {
- std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
- new base::trace_event::ProcessMemoryDump(nullptr));
base::trace_event::MemoryDumpArgs dump_args = {
base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
+ std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
+ new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
SkiaMemoryDumpProvider::GetInstance()->OnMemoryDump(
dump_args, process_memory_dump.get());
diff --git a/chromium/skia/ext/skia_utils_mac.h b/chromium/skia/ext/skia_utils_mac.h
index d15fa568447..e88c1100076 100644
--- a/chromium/skia/ext/skia_utils_mac.h
+++ b/chromium/skia/ext/skia_utils_mac.h
@@ -97,8 +97,13 @@ SK_API NSImage* SkBitmapToNSImage(const SkBitmap& icon);
// Converts a SkCanvas temporarily to a CGContext
class SK_API SkiaBitLocker {
public:
- // TODO(ccameron): delete this constructor
- explicit SkiaBitLocker(SkCanvas* canvas);
+ /**
+ User clip rect is an *additional* clip to be applied in addition to the
+ current state of the canvas, in *local* rather than device coordinates.
+ If no additional clipping is desired, pass in
+ SkIRect::MakeSize(canvas->getBaseLayerSize()) transformed by the inverse
+ CTM.
+ */
SkiaBitLocker(SkCanvas* canvas,
const SkIRect& userClipRect,
SkScalar bitmapScaleFactor = 1);
@@ -112,11 +117,6 @@ class SK_API SkiaBitLocker {
SkCanvas* canvas_;
- // If the user specified a clip rect it would draw into then the locker may
- // skip the step of searching for a rect bounding the pixels that the user
- // has drawn into.
- bool userClipRectSpecified_;
-
CGContextRef cgContext_;
// offscreen_ is only valid if useDeviceBits_ is false
SkBitmap offscreen_;
diff --git a/chromium/skia/ext/skia_utils_mac.mm b/chromium/skia/ext/skia_utils_mac.mm
index c1f1552321a..17185517350 100644
--- a/chromium/skia/ext/skia_utils_mac.mm
+++ b/chromium/skia/ext/skia_utils_mac.mm
@@ -12,7 +12,6 @@
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_nsobject.h"
-#include "skia/ext/bitmap_platform_device_mac.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/utils/mac/SkCGUtils.h"
@@ -191,10 +190,8 @@ SkBitmap CGImageToSkBitmap(CGImageRef image) {
int width = CGImageGetWidth(image);
int height = CGImageGetHeight(image);
- sk_sp<skia::BitmapPlatformDevice> device(
- skia::BitmapPlatformDevice::Create(NULL, width, height, false));
-
- sk_sp<SkCanvas> canvas(skia::CreateCanvas(device, RETURN_NULL_ON_FAILURE));
+ sk_sp<SkCanvas> canvas(skia::CreatePlatformCanvas(
+ nullptr, width, height, false, RETURN_NULL_ON_FAILURE));
ScopedPlatformPaint p(canvas.get());
CGContextRef context = p.GetPlatformSurface();
@@ -211,11 +208,7 @@ SkBitmap CGImageToSkBitmap(CGImageRef image) {
CGRect rect = CGRectMake(0, 0, width, height);
CGContextDrawImage(context, rect, image);
- // Because |device| will be cleaned up and will take its pixels with it, we
- // copy it to the stack and return it.
- SkBitmap bitmap = device->accessBitmap(false);
-
- return bitmap;
+ return skia::ReadPixels(canvas.get());
}
SkBitmap NSImageToSkBitmapWithColorSpace(
@@ -269,20 +262,10 @@ NSImage* SkBitmapToNSImage(const SkBitmap& skiaBitmap) {
return SkBitmapToNSImageWithColorSpace(skiaBitmap, colorSpace.get());
}
-SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas)
- : canvas_(canvas),
- userClipRectSpecified_(false),
- cgContext_(0),
- bitmapScaleFactor_(1),
- useDeviceBits_(false),
- bitmapIsDummy_(false) {
-}
-
SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas,
const SkIRect& userClipRect,
SkScalar bitmapScaleFactor)
: canvas_(canvas),
- userClipRectSpecified_(true),
cgContext_(0),
bitmapScaleFactor_(bitmapScaleFactor),
useDeviceBits_(false),
@@ -293,78 +276,13 @@ SkiaBitLocker::SkiaBitLocker(SkCanvas* canvas,
SkiaBitLocker::~SkiaBitLocker() {
releaseIfNeeded();
- if (userClipRectSpecified_)
- canvas_->restore();
+ canvas_->restore();
}
SkIRect SkiaBitLocker::computeDirtyRect() {
// If the user specified a clip region, assume that it was tight and that the
// dirty rect is approximately the whole bitmap.
- if (userClipRectSpecified_)
- return SkIRect::MakeWH(offscreen_.width(), offscreen_.height());
-
- // Find the bits that were drawn to.
- SkAutoLockPixels lockedPixels(offscreen_);
- const uint32_t* pixelBase
- = reinterpret_cast<uint32_t*>(offscreen_.getPixels());
- int rowPixels = offscreen_.rowBytesAsPixels();
- int width = offscreen_.width();
- int height = offscreen_.height();
- SkIRect bounds;
- bounds.fTop = 0;
- int x;
- int y = -1;
- const uint32_t* pixels = pixelBase;
- while (++y < height) {
- for (x = 0; x < width; ++x) {
- if (pixels[x]) {
- bounds.fTop = y;
- goto foundTop;
- }
- }
- pixels += rowPixels;
- }
-foundTop:
- bounds.fBottom = height;
- y = height;
- pixels = pixelBase + rowPixels * (y - 1);
- while (--y > bounds.fTop) {
- for (x = 0; x < width; ++x) {
- if (pixels[x]) {
- bounds.fBottom = y + 1;
- goto foundBottom;
- }
- }
- pixels -= rowPixels;
- }
-foundBottom:
- bounds.fLeft = 0;
- x = -1;
- while (++x < width) {
- pixels = pixelBase + rowPixels * bounds.fTop;
- for (y = bounds.fTop; y < bounds.fBottom; ++y) {
- if (pixels[x]) {
- bounds.fLeft = x;
- goto foundLeft;
- }
- pixels += rowPixels;
- }
- }
-foundLeft:
- bounds.fRight = width;
- x = width;
- while (--x > bounds.fLeft) {
- pixels = pixelBase + rowPixels * bounds.fTop;
- for (y = bounds.fTop; y < bounds.fBottom; ++y) {
- if (pixels[x]) {
- bounds.fRight = x + 1;
- goto foundRight;
- }
- pixels += rowPixels;
- }
- }
-foundRight:
- return bounds;
+ return SkIRect::MakeWH(offscreen_.width(), offscreen_.height());
}
// This must be called to balance calls to cgContext
@@ -394,6 +312,8 @@ void SkiaBitLocker::releaseIfNeeded() {
}
CGContextRef SkiaBitLocker::cgContext() {
+ releaseIfNeeded(); // This flushes any prior bitmap use
+
SkIRect clip_bounds;
if (!canvas_->getClipDeviceBounds(&clip_bounds)) {
// If the clip is empty, then there is nothing to draw. The caller may
@@ -403,18 +323,13 @@ CGContextRef SkiaBitLocker::cgContext() {
clip_bounds = SkIRect::MakeXYWH(0, 0, 1, 1);
}
- SkBaseDevice* device = canvas_->getTopDevice();
- DCHECK(device);
- if (!device)
- return 0;
-
- releaseIfNeeded(); // This flushes any prior bitmap use
-
// remember the top/left, in case we need to compose this later
bitmapOffset_.set(clip_bounds.x(), clip_bounds.y());
// Now make clip_bounds be relative to the current layer/device
- clip_bounds.offset(-device->getOrigin());
+ if (!bitmapIsDummy_) {
+ canvas_->temporary_internal_describeTopLayer(nullptr, &clip_bounds);
+ }
SkPixmap devicePixels;
skia::GetWritablePixels(canvas_, &devicePixels);
diff --git a/chromium/skia/ext/skia_utils_mac_unittest.mm b/chromium/skia/ext/skia_utils_mac_unittest.mm
index 9e4505667fa..64f20491303 100644
--- a/chromium/skia/ext/skia_utils_mac_unittest.mm
+++ b/chromium/skia/ext/skia_utils_mac_unittest.mm
@@ -33,10 +33,6 @@ class SkiaUtilsMacTest : public testing::Test {
TestTranslate = 1,
TestClip = 2,
TestXClip = TestTranslate | TestClip,
- TestNoBits = 4,
- TestTranslateNoBits = TestTranslate | TestNoBits,
- TestClipNoBits = TestClip | TestNoBits,
- TestXClipNoBits = TestXClip | TestNoBits,
};
void RunBitLockerTest(BitLockerTest test);
@@ -134,7 +130,6 @@ void SkiaUtilsMacTest::TestSkBitmap(const SkBitmap& bitmap) {
EXPECT_EQ(255u, SkColorGetA(color));
}
-// setBitmapDevice has been deprecated/removed. Is this test still useful?
void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) {
const unsigned width = 2;
const unsigned height = 2;
@@ -155,18 +150,14 @@ void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) {
canvas.clipRect(clipRect);
}
{
- skia::SkiaBitLocker bitLocker(&canvas);
+ SkIRect clip = SkIRect::MakeSize(canvas.getBaseLayerSize()).
+ makeOffset((test & TestTranslate) ? - (static_cast<int>(width)) / 2 : 0, 0);
+ skia::SkiaBitLocker bitLocker(&canvas, clip);
CGContextRef cgContext = bitLocker.cgContext();
CGColorRef testColor = CGColorGetConstantColor(kCGColorWhite);
CGContextSetFillColorWithColor(cgContext, testColor);
CGRect cgRect = {{0, 0}, {width, height}};
CGContextFillRect(cgContext, cgRect);
- if (test & TestNoBits) {
- if (test & TestClip) {
- SkRect clipRect = {0, height / 2, width, height};
- canvas.clipRect(clipRect);
- }
- }
}
const unsigned results[][storageSize] = {
{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, // identity
@@ -175,7 +166,7 @@ void SkiaUtilsMacTest::RunBitLockerTest(BitLockerTest test) {
{0xFF333333, 0xFF666666, 0xFF999999, 0xFFFFFFFF} // translate | clip
};
for (unsigned index = 0; index < storageSize; index++)
- EXPECT_EQ(results[test & ~TestNoBits][index], bits[index]);
+ EXPECT_EQ(results[test][index], bits[index]);
}
void SkiaUtilsMacTest::ShapeHelper(int width, int height,
@@ -249,21 +240,5 @@ TEST_F(SkiaUtilsMacTest, BitLocker_XClip) {
RunBitLockerTest(SkiaUtilsMacTest::TestXClip);
}
-TEST_F(SkiaUtilsMacTest, BitLocker_NoBits) {
- RunBitLockerTest(SkiaUtilsMacTest::TestNoBits);
-}
-
-TEST_F(SkiaUtilsMacTest, BitLocker_TranslateNoBits) {
- RunBitLockerTest(SkiaUtilsMacTest::TestTranslateNoBits);
-}
-
-TEST_F(SkiaUtilsMacTest, BitLocker_ClipNoBits) {
- RunBitLockerTest(SkiaUtilsMacTest::TestClipNoBits);
-}
-
-TEST_F(SkiaUtilsMacTest, BitLocker_XClipNoBits) {
- RunBitLockerTest(SkiaUtilsMacTest::TestXClipNoBits);
-}
-
} // namespace
diff --git a/chromium/skia/public/BUILD.gn b/chromium/skia/public/BUILD.gn
deleted file mode 100644
index bcc7a289dd8..00000000000
--- a/chromium/skia/public/BUILD.gn
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2015 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.
-
-source_set("public") {
- sources = [
- "type_converters.cc",
- "type_converters.h",
- ]
-
- public_deps = [
- "//skia/public/interfaces",
- ]
-
- deps = [
- "//base",
- "//mojo/public/cpp/bindings",
- "//skia",
- ]
-}
diff --git a/chromium/skia/public/interfaces/BUILD.gn b/chromium/skia/public/interfaces/BUILD.gn
index e2ffdf006ad..8a19498a5dc 100644
--- a/chromium/skia/public/interfaces/BUILD.gn
+++ b/chromium/skia/public/interfaces/BUILD.gn
@@ -7,5 +7,17 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
"bitmap.mojom",
+ "image_filter.mojom",
+ ]
+}
+
+mojom("test_interfaces") {
+ testonly = true
+ sources = [
+ "test/traits_test_service.mojom",
+ ]
+
+ public_deps = [
+ ":interfaces",
]
}
diff --git a/chromium/skia/public/interfaces/OWNERS b/chromium/skia/public/interfaces/OWNERS
new file mode 100644
index 00000000000..1841ff6198d
--- /dev/null
+++ b/chromium/skia/public/interfaces/OWNERS
@@ -0,0 +1,5 @@
+per-file *_struct_traits*.*=set noparent
+per-file *_struct_traits*.*=file://ipc/SECURITY_OWNERS
+
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
diff --git a/chromium/skia/public/interfaces/bitmap.mojom b/chromium/skia/public/interfaces/bitmap.mojom
index 340e3f3d8c7..9d50e4c54c7 100644
--- a/chromium/skia/public/interfaces/bitmap.mojom
+++ b/chromium/skia/public/interfaces/bitmap.mojom
@@ -25,7 +25,8 @@ enum AlphaType {
UNPREMUL,
};
-// Mirror of SkColorProfileType.
+// Capture of the (simple) gamma of SkColorSpace. Need to eventually
+// serialize the actual colorspace object.
enum ColorProfileType {
LINEAR,
SRGB,
diff --git a/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.cc b/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.cc
new file mode 100644
index 00000000000..1e9345295f3
--- /dev/null
+++ b/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.cc
@@ -0,0 +1,202 @@
+// Copyright 2016 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 "skia/public/interfaces/bitmap_skbitmap_struct_traits.h"
+
+namespace mojo {
+
+namespace {
+
+SkColorType MojoColorTypeToSk(skia::mojom::ColorType type) {
+ switch (type) {
+ case skia::mojom::ColorType::UNKNOWN:
+ return kUnknown_SkColorType;
+ case skia::mojom::ColorType::ALPHA_8:
+ return kAlpha_8_SkColorType;
+ case skia::mojom::ColorType::RGB_565:
+ return kRGB_565_SkColorType;
+ case skia::mojom::ColorType::ARGB_4444:
+ return kARGB_4444_SkColorType;
+ case skia::mojom::ColorType::RGBA_8888:
+ return kRGBA_8888_SkColorType;
+ case skia::mojom::ColorType::BGRA_8888:
+ return kBGRA_8888_SkColorType;
+ case skia::mojom::ColorType::INDEX_8:
+ return kIndex_8_SkColorType;
+ case skia::mojom::ColorType::GRAY_8:
+ return kGray_8_SkColorType;
+ }
+ NOTREACHED();
+ return kUnknown_SkColorType;
+}
+
+SkAlphaType MojoAlphaTypeToSk(skia::mojom::AlphaType type) {
+ switch (type) {
+ case skia::mojom::AlphaType::UNKNOWN:
+ return kUnknown_SkAlphaType;
+ case skia::mojom::AlphaType::ALPHA_TYPE_OPAQUE:
+ return kOpaque_SkAlphaType;
+ case skia::mojom::AlphaType::PREMUL:
+ return kPremul_SkAlphaType;
+ case skia::mojom::AlphaType::UNPREMUL:
+ return kUnpremul_SkAlphaType;
+ }
+ NOTREACHED();
+ return kUnknown_SkAlphaType;
+}
+
+sk_sp<SkColorSpace> MojoProfileTypeToSk(skia::mojom::ColorProfileType type) {
+ switch (type) {
+ case skia::mojom::ColorProfileType::LINEAR:
+ return nullptr;
+ case skia::mojom::ColorProfileType::SRGB:
+ return SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ }
+ NOTREACHED();
+ return nullptr;
+}
+
+skia::mojom::ColorType SkColorTypeToMojo(SkColorType type) {
+ switch (type) {
+ case kUnknown_SkColorType:
+ return skia::mojom::ColorType::UNKNOWN;
+ case kAlpha_8_SkColorType:
+ return skia::mojom::ColorType::ALPHA_8;
+ case kRGB_565_SkColorType:
+ return skia::mojom::ColorType::RGB_565;
+ case kARGB_4444_SkColorType:
+ return skia::mojom::ColorType::ARGB_4444;
+ case kRGBA_8888_SkColorType:
+ return skia::mojom::ColorType::RGBA_8888;
+ case kBGRA_8888_SkColorType:
+ return skia::mojom::ColorType::BGRA_8888;
+ case kIndex_8_SkColorType:
+ return skia::mojom::ColorType::INDEX_8;
+ case kGray_8_SkColorType:
+ return skia::mojom::ColorType::GRAY_8;
+ case kRGBA_F16_SkColorType:
+ NOTREACHED();
+ return skia::mojom::ColorType::UNKNOWN;
+ }
+ NOTREACHED();
+ return skia::mojom::ColorType::UNKNOWN;
+}
+
+skia::mojom::AlphaType SkAlphaTypeToMojo(SkAlphaType type) {
+ switch (type) {
+ case kUnknown_SkAlphaType:
+ return skia::mojom::AlphaType::UNKNOWN;
+ case kOpaque_SkAlphaType:
+ return skia::mojom::AlphaType::ALPHA_TYPE_OPAQUE;
+ case kPremul_SkAlphaType:
+ return skia::mojom::AlphaType::PREMUL;
+ case kUnpremul_SkAlphaType:
+ return skia::mojom::AlphaType::UNPREMUL;
+ }
+ NOTREACHED();
+ return skia::mojom::AlphaType::UNKNOWN;
+}
+
+skia::mojom::ColorProfileType SkColorSpaceToMojo(SkColorSpace* cs) {
+ if (cs && cs->gammaCloseToSRGB())
+ return skia::mojom::ColorProfileType::SRGB;
+ return skia::mojom::ColorProfileType::LINEAR;
+}
+
+} // namespace
+
+// static
+bool StructTraits<skia::mojom::Bitmap, SkBitmap>::IsNull(const SkBitmap& b) {
+ return b.isNull();
+}
+
+// static
+void StructTraits<skia::mojom::Bitmap, SkBitmap>::SetToNull(SkBitmap* b) {
+ b->reset();
+}
+
+// static
+skia::mojom::ColorType StructTraits<skia::mojom::Bitmap, SkBitmap>::color_type(
+ const SkBitmap& b) {
+ return SkColorTypeToMojo(b.colorType());
+}
+
+// static
+skia::mojom::AlphaType StructTraits<skia::mojom::Bitmap, SkBitmap>::alpha_type(
+ const SkBitmap& b) {
+ return SkAlphaTypeToMojo(b.alphaType());
+}
+
+// static
+skia::mojom::ColorProfileType
+StructTraits<skia::mojom::Bitmap, SkBitmap>::profile_type(const SkBitmap& b) {
+ return SkColorSpaceToMojo(b.colorSpace());
+}
+
+// static
+uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::width(const SkBitmap& b) {
+ return b.width() < 0 ? 0 : static_cast<uint32_t>(b.width());
+}
+
+// static
+uint32_t StructTraits<skia::mojom::Bitmap, SkBitmap>::height(
+ const SkBitmap& b) {
+ return b.height() < 0 ? 0 : static_cast<uint32_t>(b.height());
+}
+
+// static
+BitmapBuffer StructTraits<skia::mojom::Bitmap, SkBitmap>::pixel_data(
+ const SkBitmap& b) {
+ return {b.getSize(), b.getSize(), static_cast<uint8_t*>(b.getPixels())};
+}
+
+// static
+bool StructTraits<skia::mojom::Bitmap, SkBitmap>::Read(
+ skia::mojom::BitmapDataView data,
+ SkBitmap* b) {
+ // TODO: Ensure width and height are reasonable, eg. <= kMaxBitmapSize?
+ *b = SkBitmap();
+ if (!b->tryAllocPixels(SkImageInfo::Make(
+ data.width(), data.height(), MojoColorTypeToSk(data.color_type()),
+ MojoAlphaTypeToSk(data.alpha_type()),
+ MojoProfileTypeToSk(data.profile_type())))) {
+ return false;
+ }
+
+ // If the image is empty, return success after setting the image info.
+ if (data.width() == 0 || data.height() == 0)
+ return true;
+
+ SkAutoPixmapUnlock pixmap;
+ if (static_cast<uint32_t>(b->width()) != data.width() ||
+ static_cast<uint32_t>(b->height()) != data.height() ||
+ !b->requestLock(&pixmap) || !b->lockPixelsAreWritable() ||
+ !b->readyToDraw()) {
+ return false;
+ }
+
+ BitmapBuffer bitmap_buffer = {0, b->getSize(),
+ static_cast<uint8_t*>(b->getPixels())};
+ if (!data.ReadPixelData(&bitmap_buffer) || bitmap_buffer.size != b->getSize())
+ return false;
+
+ b->notifyPixelsChanged();
+ return true;
+}
+
+// static
+void* StructTraits<skia::mojom::Bitmap, SkBitmap>::SetUpContext(
+ const SkBitmap& b) {
+ b.lockPixels();
+ return nullptr;
+}
+
+// static
+void StructTraits<skia::mojom::Bitmap, SkBitmap>::TearDownContext(
+ const SkBitmap& b,
+ void* context) {
+ b.unlockPixels();
+}
+
+} // namespace mojo
diff --git a/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.h b/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.h
new file mode 100644
index 00000000000..91a51ff266f
--- /dev/null
+++ b/chromium/skia/public/interfaces/bitmap_skbitmap_struct_traits.h
@@ -0,0 +1,35 @@
+// Copyright 2016 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 SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
+#define SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
+
+#include "mojo/public/cpp/bindings/array_traits.h"
+#include "skia/public/interfaces/bitmap.mojom.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+
+namespace mojo {
+
+// A buffer used to read pixel data directly from BitmapDataView to SkBitmap.
+using BitmapBuffer = CArray<uint8_t>;
+
+// Struct traits to use SkBitmap for skia::mojom::Bitmap in Chrome C++ code.
+template <>
+struct StructTraits<skia::mojom::Bitmap, SkBitmap> {
+ static bool IsNull(const SkBitmap& b);
+ static void SetToNull(SkBitmap* b);
+ static skia::mojom::ColorType color_type(const SkBitmap& b);
+ static skia::mojom::AlphaType alpha_type(const SkBitmap& b);
+ static skia::mojom::ColorProfileType profile_type(const SkBitmap& b);
+ static uint32_t width(const SkBitmap& b);
+ static uint32_t height(const SkBitmap& b);
+ static BitmapBuffer pixel_data(const SkBitmap& b);
+ static bool Read(skia::mojom::BitmapDataView data, SkBitmap* b);
+ static void* SetUpContext(const SkBitmap& b);
+ static void TearDownContext(const SkBitmap& b, void* context);
+};
+
+} // namespace mojo
+
+#endif // SKIA_PUBLIC_INTERFACES_BITMAP_SKBITMAP_STRUCT_TRAITS_H_
diff --git a/chromium/skia/public/interfaces/image_filter.mojom b/chromium/skia/public/interfaces/image_filter.mojom
new file mode 100644
index 00000000000..4db9d20c0c7
--- /dev/null
+++ b/chromium/skia/public/interfaces/image_filter.mojom
@@ -0,0 +1,10 @@
+// Copyright 2016 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.
+
+module skia.mojom;
+
+// This struct contains a serialized SkImageFilter.
+struct ImageFilter {
+ array<uint8> data;
+};
diff --git a/chromium/skia/public/interfaces/image_filter.typemap b/chromium/skia/public/interfaces/image_filter.typemap
new file mode 100644
index 00000000000..58474f03604
--- /dev/null
+++ b/chromium/skia/public/interfaces/image_filter.typemap
@@ -0,0 +1,11 @@
+# Copyright 2016 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.
+
+mojom = "//skia/public/interfaces/image_filter.mojom"
+public_headers = [ "//third_party/skia/include/core/SkImageFilter.h" ]
+traits_headers = [ "//skia/public/interfaces/image_filter_struct_traits.h" ]
+sources = [ "//skia/public/interfaces/image_filter_struct_traits.cc" ]
+deps = [ "//mojo/public/cpp/bindings" ]
+public_deps = [ "//skia" ]
+type_mappings = [ "skia.mojom.ImageFilter=sk_sp<SkImageFilter>" ]
diff --git a/chromium/skia/public/interfaces/image_filter_struct_traits.cc b/chromium/skia/public/interfaces/image_filter_struct_traits.cc
new file mode 100644
index 00000000000..b21d6d41f9a
--- /dev/null
+++ b/chromium/skia/public/interfaces/image_filter_struct_traits.cc
@@ -0,0 +1,50 @@
+// Copyright 2016 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 "skia/public/interfaces/image_filter_struct_traits.h"
+
+namespace mojo {
+
+ImageFilterBuffer::ImageFilterBuffer() {}
+
+ImageFilterBuffer::ImageFilterBuffer(const ImageFilterBuffer& other) = default;
+
+ImageFilterBuffer::~ImageFilterBuffer() = default;
+
+// static
+size_t ArrayTraits<ImageFilterBuffer>::GetSize(const ImageFilterBuffer& b) {
+ return b.data->size();
+}
+
+// static
+uint8_t* ArrayTraits<ImageFilterBuffer>::GetData(ImageFilterBuffer& b) {
+ return static_cast<uint8_t*>(b.data->writable_data());
+}
+
+// static
+const uint8_t* ArrayTraits<ImageFilterBuffer>::GetData(
+ const ImageFilterBuffer& b) {
+ return b.data->bytes();
+}
+
+// static
+uint8_t& ArrayTraits<ImageFilterBuffer>::GetAt(ImageFilterBuffer& b, size_t i) {
+ return *(static_cast<uint8_t*>(b.data->writable_data()) + i);
+}
+
+// static
+const uint8_t& ArrayTraits<ImageFilterBuffer>::GetAt(const ImageFilterBuffer& b,
+ size_t i) {
+ return *(b.data->bytes() + i);
+}
+
+// static
+bool ArrayTraits<ImageFilterBuffer>::Resize(ImageFilterBuffer& b, size_t size) {
+ if (b.data)
+ return size == b.data->size();
+ b.data = SkData::MakeUninitialized(size);
+ return true;
+}
+
+} // namespace mojo
diff --git a/chromium/skia/public/interfaces/image_filter_struct_traits.h b/chromium/skia/public/interfaces/image_filter_struct_traits.h
new file mode 100644
index 00000000000..aa3d003f459
--- /dev/null
+++ b/chromium/skia/public/interfaces/image_filter_struct_traits.h
@@ -0,0 +1,56 @@
+// Copyright 2016 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 SKIA_PUBLIC_INTERFACES_IMAGE_FILTER_STRUCT_TRAITS_H_
+#define SKIA_PUBLIC_INTERFACES_IMAGE_FILTER_STRUCT_TRAITS_H_
+
+#include "skia/public/interfaces/image_filter.mojom.h"
+#include "third_party/skia/include/core/SkData.h"
+#include "third_party/skia/include/core/SkImageFilter.h"
+#include "third_party/skia/include/core/SkFlattenableSerialization.h"
+
+namespace mojo {
+
+struct ImageFilterBuffer {
+ ImageFilterBuffer();
+ ImageFilterBuffer(const ImageFilterBuffer& other);
+ ~ImageFilterBuffer();
+ sk_sp<SkData> data;
+};
+
+template <>
+struct ArrayTraits<ImageFilterBuffer> {
+ using Element = uint8_t;
+ static size_t GetSize(const ImageFilterBuffer& b);
+ static uint8_t* GetData(ImageFilterBuffer& b);
+ static const uint8_t* GetData(const ImageFilterBuffer& b);
+ static uint8_t& GetAt(ImageFilterBuffer& b, size_t i);
+ static const uint8_t& GetAt(const ImageFilterBuffer& b, size_t i);
+ static bool Resize(ImageFilterBuffer& b, size_t size);
+};
+
+template <>
+struct StructTraits<skia::mojom::ImageFilter, sk_sp<SkImageFilter>> {
+ static ImageFilterBuffer data(const sk_sp<SkImageFilter>& filter) {
+ ImageFilterBuffer buffer;
+ buffer.data = sk_sp<SkData>(SkValidatingSerializeFlattenable(filter.get()));
+ return buffer;
+ }
+
+ static bool Read(skia::mojom::ImageFilterDataView data,
+ sk_sp<SkImageFilter>* out) {
+ ImageFilterBuffer buffer;
+ if (!data.ReadData(&buffer))
+ return false;
+ SkFlattenable* flattenable = SkValidatingDeserializeFlattenable(
+ buffer.data->bytes(), buffer.data->size(),
+ SkImageFilter::GetFlattenableType());
+ *out = sk_sp<SkImageFilter>(static_cast<SkImageFilter*>(flattenable));
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // SKIA_PUBLIC_INTERFACES_IMAGE_FILTER_STRUCT_TRAITS_H_
diff --git a/chromium/skia/public/interfaces/skbitmap.typemap b/chromium/skia/public/interfaces/skbitmap.typemap
new file mode 100644
index 00000000000..df9d171930a
--- /dev/null
+++ b/chromium/skia/public/interfaces/skbitmap.typemap
@@ -0,0 +1,11 @@
+# Copyright 2016 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.
+
+mojom = "//skia/public/interfaces/bitmap.mojom"
+public_headers = [ "//third_party/skia/include/core/SkBitmap.h" ]
+traits_headers = [ "//skia/public/interfaces/bitmap_skbitmap_struct_traits.h" ]
+sources = [ "//skia/public/interfaces/bitmap_skbitmap_struct_traits.cc" ]
+deps = [ "//mojo/public/cpp/bindings" ]
+public_deps = [ "//skia" ]
+type_mappings = [ "skia.mojom.Bitmap=SkBitmap" ]
diff --git a/chromium/skia/public/interfaces/typemaps.gni b/chromium/skia/public/interfaces/typemaps.gni
new file mode 100644
index 00000000000..eee4dd2a011
--- /dev/null
+++ b/chromium/skia/public/interfaces/typemaps.gni
@@ -0,0 +1,8 @@
+# Copyright 2016 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.
+
+typemaps = [
+ "//skia/public/interfaces/image_filter.typemap",
+ "//skia/public/interfaces/skbitmap.typemap",
+]
diff --git a/chromium/skia/public/type_converters.cc b/chromium/skia/public/type_converters.cc
deleted file mode 100644
index 939bf6db14b..00000000000
--- a/chromium/skia/public/type_converters.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2015 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 "skia/public/type_converters.h"
-
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-
-#include "base/logging.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace mojo {
-
-namespace {
-
-SkColorType MojoColorTypeToSk(skia::mojom::ColorType type) {
- switch (type) {
- case skia::mojom::ColorType::UNKNOWN:
- return kUnknown_SkColorType;
- case skia::mojom::ColorType::ALPHA_8:
- return kAlpha_8_SkColorType;
- case skia::mojom::ColorType::RGB_565:
- return kRGB_565_SkColorType;
- case skia::mojom::ColorType::ARGB_4444:
- return kARGB_4444_SkColorType;
- case skia::mojom::ColorType::RGBA_8888:
- return kRGBA_8888_SkColorType;
- case skia::mojom::ColorType::BGRA_8888:
- return kBGRA_8888_SkColorType;
- case skia::mojom::ColorType::INDEX_8:
- return kIndex_8_SkColorType;
- case skia::mojom::ColorType::GRAY_8:
- return kGray_8_SkColorType;
- default:
- NOTREACHED();
- }
- return kUnknown_SkColorType;
-}
-
-SkAlphaType MojoAlphaTypeToSk(skia::mojom::AlphaType type) {
- switch (type) {
- case skia::mojom::AlphaType::UNKNOWN:
- return kUnknown_SkAlphaType;
- case skia::mojom::AlphaType::ALPHA_TYPE_OPAQUE:
- return kOpaque_SkAlphaType;
- case skia::mojom::AlphaType::PREMUL:
- return kPremul_SkAlphaType;
- case skia::mojom::AlphaType::UNPREMUL:
- return kUnpremul_SkAlphaType;
- default:
- NOTREACHED();
- }
- return kUnknown_SkAlphaType;
-}
-
-skia::mojom::ColorType SkColorTypeToMojo(SkColorType type) {
- switch (type) {
- case kUnknown_SkColorType:
- return skia::mojom::ColorType::UNKNOWN;
- case kAlpha_8_SkColorType:
- return skia::mojom::ColorType::ALPHA_8;
- case kRGB_565_SkColorType:
- return skia::mojom::ColorType::RGB_565;
- case kARGB_4444_SkColorType:
- return skia::mojom::ColorType::ARGB_4444;
- case kRGBA_8888_SkColorType:
- return skia::mojom::ColorType::RGBA_8888;
- case kBGRA_8888_SkColorType:
- return skia::mojom::ColorType::BGRA_8888;
- case kIndex_8_SkColorType:
- return skia::mojom::ColorType::INDEX_8;
- case kGray_8_SkColorType:
- return skia::mojom::ColorType::GRAY_8;
- default:
- NOTREACHED();
- }
- return skia::mojom::ColorType::UNKNOWN;
-}
-
-skia::mojom::AlphaType SkAlphaTypeToMojo(SkAlphaType type) {
- switch (type) {
- case kUnknown_SkAlphaType:
- return skia::mojom::AlphaType::UNKNOWN;
- case kOpaque_SkAlphaType:
- return skia::mojom::AlphaType::ALPHA_TYPE_OPAQUE;
- case kPremul_SkAlphaType:
- return skia::mojom::AlphaType::PREMUL;
- case kUnpremul_SkAlphaType:
- return skia::mojom::AlphaType::UNPREMUL;
- default:
- NOTREACHED();
- }
- return skia::mojom::AlphaType::UNKNOWN;
-}
-
-} // namespace
-
-SkBitmap TypeConverter<SkBitmap, skia::mojom::BitmapPtr>::Convert(
- const skia::mojom::BitmapPtr& image) {
- SkBitmap bitmap;
- if (image.is_null())
- return bitmap;
- if (!bitmap.tryAllocPixels(SkImageInfo::Make(
- image->width, image->height, MojoColorTypeToSk(image->color_type),
- MojoAlphaTypeToSk(image->alpha_type)))) {
- return SkBitmap();
- }
- if (bitmap.getSize() != image->pixel_data.size() || !bitmap.getPixels()) {
- return SkBitmap();
- }
-
- memcpy(bitmap.getPixels(), &image->pixel_data[0], bitmap.getSize());
- return bitmap;
-}
-
-skia::mojom::BitmapPtr TypeConverter<skia::mojom::BitmapPtr, SkBitmap>::Convert(
- const SkBitmap& bitmap) {
- if (bitmap.isNull())
- return nullptr;
-
- // NOTE: This code doesn't correctly serialize Index8 bitmaps.
- const SkImageInfo& info = bitmap.info();
- DCHECK_NE(info.colorType(), kIndex_8_SkColorType);
- if (info.colorType() == kIndex_8_SkColorType)
- return nullptr;
- skia::mojom::BitmapPtr result = skia::mojom::Bitmap::New();
- result->color_type = SkColorTypeToMojo(info.colorType());
- result->alpha_type = SkAlphaTypeToMojo(info.alphaType());
- result->width = info.width();
- result->height = info.height();
- size_t size = bitmap.getSize();
- size_t row_bytes = bitmap.rowBytes();
- result->pixel_data = mojo::Array<uint8_t>::New(size);
- if (!bitmap.readPixels(info, &result->pixel_data[0], row_bytes, 0, 0))
- return nullptr;
- return result;
-}
-
-} // namespace mojo
diff --git a/chromium/skia/public/type_converters.h b/chromium/skia/public/type_converters.h
deleted file mode 100644
index a7f71d8e02e..00000000000
--- a/chromium/skia/public/type_converters.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2015 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 SKIA_PUBLIC_TYPE_CONVERTERS_H_
-#define SKIA_PUBLIC_TYPE_CONVERTERS_H_
-
-#include "skia/public/interfaces/bitmap.mojom.h"
-
-class SkBitmap;
-
-namespace mojo {
-
-template <>
-struct TypeConverter<SkBitmap, skia::mojom::BitmapPtr> {
- static SkBitmap Convert(const skia::mojom::BitmapPtr& image);
-};
-
-template <>
-struct TypeConverter<skia::mojom::BitmapPtr, SkBitmap> {
- static skia::mojom::BitmapPtr Convert(const SkBitmap& bitmap);
-};
-
-} // namespace mojo
-
-#endif // SKIA_PUBLIC_TYPE_CONVERTERS_H_
diff --git a/chromium/skia/skia.gyp b/chromium/skia/skia.gyp
index 2103c4bd76d..4baf2b0d892 100644
--- a/chromium/skia/skia.gyp
+++ b/chromium/skia/skia.gyp
@@ -171,6 +171,19 @@
],
},
{
+ 'target_name': 'skia_interfaces_mojom',
+ 'type': 'none',
+ 'variables': {
+ 'mojom_files': [
+ 'public/interfaces/bitmap.mojom',
+ ],
+ 'mojom_typemaps': [
+ 'public/interfaces/skbitmap.typemap',
+ ],
+ },
+ 'includes': [ '../mojo/mojom_bindings_generator_explicit.gypi' ],
+ },
+ {
'target_name': 'skia_mojo',
'type': 'static_library',
# The optimize: 'max' scattered throughout are particularly
@@ -180,17 +193,16 @@
'variables': {
'optimize': 'max',
},
+ 'sources': [
+ '../skia/public/interfaces/bitmap_skbitmap_struct_traits.cc',
+ ],
'dependencies': [
'skia',
+ 'skia_interfaces_mojom',
'../base/base.gyp:base',
],
- 'includes': [
- '../mojo/mojom_bindings_generator.gypi',
- ],
- 'sources': [
- # Note: file list duplicated in GN build.
- 'public/interfaces/bitmap.mojom',
- 'public/type_converters.cc',
+ 'export_dependent_settings': [
+ 'skia',
],
},
],
diff --git a/chromium/skia/skia_common.gypi b/chromium/skia/skia_common.gypi
index 21801cc5a1e..c57c5952e0a 100644
--- a/chromium/skia/skia_common.gypi
+++ b/chromium/skia/skia_common.gypi
@@ -31,7 +31,12 @@
}],
[ 'OS == "ios"', {
'defines': [
+ # When targetting iOS and using gyp to generate the build files, it is
+ # not possible to select files to build depending on the architecture
+ # (i.e. it is not possible to use hand optimized assembly version). In
+ # that configuration, disable all optimisation.
'SK_BUILD_FOR_IOS',
+ 'SK_BUILD_NO_OPTS',
],
}],
[ 'OS != "mac"', {
diff --git a/chromium/skia/skia_library.gypi b/chromium/skia/skia_library.gypi
index 21a64d000fa..ec218e82a01 100644
--- a/chromium/skia/skia_library.gypi
+++ b/chromium/skia/skia_library.gypi
@@ -285,8 +285,7 @@
],
'xcode_settings' : {
'WARNING_CFLAGS': [
- # SkFontHost_mac.cpp uses API deprecated in iOS 7.
- # crbug.com/408571
+ # SkFontHost_mac.cpp uses API deprecated in iOS 7, crbug.com/408571
'-Wno-deprecated-declarations',
],
},
diff --git a/chromium/skia/skia_tests.gyp b/chromium/skia/skia_tests.gyp
index fbb9b1c83a0..f5ca5f600ed 100644
--- a/chromium/skia/skia_tests.gyp
+++ b/chromium/skia/skia_tests.gyp
@@ -25,7 +25,6 @@
'ext/image_operations_unittest.cc',
'ext/platform_canvas_unittest.cc',
'ext/recursive_gaussian_convolution_unittest.cc',
- 'ext/refptr_unittest.cc',
'ext/skia_memory_dump_provider_unittest.cc',
'ext/skia_utils_ios_unittest.mm',
'ext/skia_utils_mac_unittest.mm',