Remove uses of symbols in SkColorPriv.h
Skia is removing SkColorPriv.h from the public API. Chromium tends to manipulate SkPMColor a bit (which had some utilities in that header), so we created SkPMColor.h for that in [1] This updates those call-sites, removes unnecessary references to that header, and inlines some functions into Chromium where we are removing those from the public API. The replacements should be functionally the same, although there might be performance changes from some no-longer-inlineable functions. If those are critical, we can follow-up with some Chromium specific logic for dealing with Skia's Native32 (N32) backend format as appropriate. [1] http://review.skia.org/958818 Change-Id: I4a333c612b53625538a629fcc3f03b803190ed28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6318302 Commit-Queue: Kaylee Lubick <kjlubick@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/main@{#1429429}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
778f7e3086
commit
6b88a2263d
components
safe_browsing
content
viz
service
display
content/renderer
media/renderers
skia
third_party/blink/renderer/platform/image-decoders
ui
@ -18,9 +18,9 @@
|
||||
#include "components/safe_browsing/core/common/proto/csd.pb.h"
|
||||
#include "skia/ext/image_operations.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
#include "third_party/skia/include/core/SkPixmap.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/color_utils.h"
|
||||
|
||||
namespace safe_browsing::visual_utils {
|
||||
@ -167,7 +167,7 @@ std::unique_ptr<SkBitmap> BlockMeanAverage(const SkBitmap& image,
|
||||
int b_mean = b_total / sample_count;
|
||||
|
||||
*target->getAddr32(block_x, block_y) =
|
||||
SkPackARGB32(255, r_mean, g_mean, b_mean);
|
||||
SkPMColorSetARGB(255, r_mean, g_mean, b_mean);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,16 +12,16 @@
|
||||
#include "components/safe_browsing/core/common/features.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
|
||||
namespace safe_browsing::visual_utils {
|
||||
|
||||
namespace {
|
||||
|
||||
const SkPMColor kSkPMRed = SkPackARGB32(255, 255, 0, 0);
|
||||
const SkPMColor kSkPMGreen = SkPackARGB32(255, 0, 255, 0);
|
||||
const SkPMColor kSkPMBlue = SkPackARGB32(255, 0, 0, 255);
|
||||
const SkPMColor kSkPMRed = SkPMColorSetARGB(255, 255, 0, 0);
|
||||
const SkPMColor kSkPMGreen = SkPMColorSetARGB(255, 0, 255, 0);
|
||||
const SkPMColor kSkPMBlue = SkPMColorSetARGB(255, 0, 0, 255);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -61,11 +61,11 @@
|
||||
#include "media/base/video_types.h"
|
||||
#include "media/renderers/video_resource_updater.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkMatrix.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/color_transform.h"
|
||||
#include "ui/gfx/geometry/mask_filter_info.h"
|
||||
#include "ui/gfx/geometry/skia_conversions.h"
|
||||
@ -273,13 +273,15 @@ void CreateTestTwoColoredTextureDrawQuad(
|
||||
SkPMColor pixel_color_one =
|
||||
premultiplied_alpha
|
||||
? SkPreMultiplyColor(texel_color_one.toSkColor())
|
||||
: SkPackARGB32(255 * texel_color_one.fA, 255 * texel_color_one.fR,
|
||||
255 * texel_color_one.fG, 255 * texel_color_one.fB);
|
||||
: SkPMColorSetARGB(255 * texel_color_one.fA, 255 * texel_color_one.fR,
|
||||
255 * texel_color_one.fG,
|
||||
255 * texel_color_one.fB);
|
||||
SkPMColor pixel_color_two =
|
||||
premultiplied_alpha
|
||||
? SkPreMultiplyColor(texel_color_two.toSkColor())
|
||||
: SkPackARGB32(255 * texel_color_two.fA, 255 * texel_color_two.fR,
|
||||
255 * texel_color_two.fG, 255 * texel_color_two.fB);
|
||||
: SkPMColorSetARGB(255 * texel_color_two.fA, 255 * texel_color_two.fR,
|
||||
255 * texel_color_two.fG,
|
||||
255 * texel_color_two.fB);
|
||||
// The default color is texel_color_one
|
||||
std::vector<uint32_t> pixels(rect.size().GetArea(), pixel_color_one);
|
||||
if (half_and_half) {
|
||||
@ -367,8 +369,8 @@ void CreateTestTextureDrawQuad(
|
||||
SkPMColor pixel_color =
|
||||
premultiplied_alpha
|
||||
? SkPreMultiplyColor(texel_color.toSkColor())
|
||||
: SkPackARGB32(texel_color.fA * 255, texel_color.fR * 255,
|
||||
texel_color.fG * 255, texel_color.fB * 255);
|
||||
: SkPMColorSetARGB(texel_color.fA * 255, texel_color.fR * 255,
|
||||
texel_color.fG * 255, texel_color.fB * 255);
|
||||
size_t num_pixels = static_cast<size_t>(rect.width()) * rect.height();
|
||||
std::vector<uint32_t> pixels(num_pixels, pixel_color);
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "skia/ext/legacy_display_globals.h"
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkPixmap.h"
|
||||
#include "ui/surface/transport_dib.h"
|
||||
|
||||
|
@ -34,10 +34,10 @@
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkGraphics.h"
|
||||
#include "third_party/skia/include/core/SkPicture.h"
|
||||
#include "third_party/skia/include/core/SkStream.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/codec/jpeg_codec.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
#include "ui/gfx/geometry/rect_conversions.h"
|
||||
@ -230,10 +230,10 @@ void SkiaBenchmarking::Rasterize(gin::Arguments* args) {
|
||||
// Swizzle from native Skia format to RGBA as we copy out.
|
||||
for (size_t i = 0; i < bitmap.computeByteSize(); i += 4) {
|
||||
uint32_t c = packed_pixels[i >> 2];
|
||||
buffer_pixels[i] = SkGetPackedR32(c);
|
||||
buffer_pixels[i + 1] = SkGetPackedG32(c);
|
||||
buffer_pixels[i + 2] = SkGetPackedB32(c);
|
||||
buffer_pixels[i + 3] = SkGetPackedA32(c);
|
||||
buffer_pixels[i] = SkPMColorGetR(c);
|
||||
buffer_pixels[i + 1] = SkPMColorGetG(c);
|
||||
buffer_pixels[i + 2] = SkPMColorGetB(c);
|
||||
buffer_pixels[i + 3] = SkPMColorGetA(c);
|
||||
}
|
||||
|
||||
args->Return(gin::DataObjectBuilder(isolate)
|
||||
|
@ -40,11 +40,11 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/libyuv/include/libyuv/convert.h"
|
||||
#include "third_party/libyuv/include/libyuv/scale.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/color_space.h"
|
||||
#include "ui/gfx/geometry/rect_f.h"
|
||||
#include "ui/gl/gl_implementation.h"
|
||||
@ -832,19 +832,19 @@ TEST_F(PaintCanvasVideoRendererTest, I420WithFilters) {
|
||||
int i = 1;
|
||||
int j = 1;
|
||||
uint32_t color = rgba[i * kImgWidth + j];
|
||||
EXPECT_EQ(SkGetPackedA32(color), 255u);
|
||||
EXPECT_EQ(SkGetPackedR32(color), 249u);
|
||||
EXPECT_EQ(SkGetPackedG32(color), 1u);
|
||||
EXPECT_EQ(SkGetPackedB32(color), 7u);
|
||||
EXPECT_EQ(SkPMColorGetA(color), 255u);
|
||||
EXPECT_EQ(SkPMColorGetR(color), 249u);
|
||||
EXPECT_EQ(SkPMColorGetG(color), 1u);
|
||||
EXPECT_EQ(SkPMColorGetB(color), 7u);
|
||||
// The pixel at coordinates (2, 2) will have U = 105 and V = 235 if nearest
|
||||
// neighbor is used. (The correct values are U = 101 and V = 239.)
|
||||
i = 2;
|
||||
j = 2;
|
||||
color = rgba[i * kImgWidth + j];
|
||||
EXPECT_EQ(SkGetPackedA32(color), 255u);
|
||||
EXPECT_EQ(SkGetPackedR32(color), 226u);
|
||||
EXPECT_EQ(SkGetPackedG32(color), 7u);
|
||||
EXPECT_EQ(SkGetPackedB32(color), 35u);
|
||||
EXPECT_EQ(SkPMColorGetA(color), 255u);
|
||||
EXPECT_EQ(SkPMColorGetR(color), 226u);
|
||||
EXPECT_EQ(SkPMColorGetG(color), 7u);
|
||||
EXPECT_EQ(SkPMColorGetB(color), 35u);
|
||||
|
||||
// Then convert with kFilterBilinear (bilinear interpolation).
|
||||
PaintCanvasVideoRenderer::ConvertVideoFrameToRGBPixels(
|
||||
@ -856,19 +856,19 @@ TEST_F(PaintCanvasVideoRendererTest, I420WithFilters) {
|
||||
i = 1;
|
||||
j = 1;
|
||||
color = rgba[i * kImgWidth + j];
|
||||
EXPECT_EQ(SkGetPackedA32(color), 255u);
|
||||
EXPECT_EQ(SkGetPackedR32(color), 243u);
|
||||
EXPECT_EQ(SkGetPackedG32(color), 2u);
|
||||
EXPECT_EQ(SkGetPackedB32(color), 14u);
|
||||
EXPECT_EQ(SkPMColorGetA(color), 255u);
|
||||
EXPECT_EQ(SkPMColorGetR(color), 243u);
|
||||
EXPECT_EQ(SkPMColorGetG(color), 2u);
|
||||
EXPECT_EQ(SkPMColorGetB(color), 14u);
|
||||
// The pixel at coordinates (2, 2) will have the correct values U = 101 and
|
||||
// V = 239 if bilinear interpolation is used.
|
||||
i = 2;
|
||||
j = 2;
|
||||
color = rgba[i * kImgWidth + j];
|
||||
EXPECT_EQ(SkGetPackedA32(color), 255u);
|
||||
EXPECT_EQ(SkGetPackedR32(color), 232u);
|
||||
EXPECT_EQ(SkGetPackedG32(color), 5u);
|
||||
EXPECT_EQ(SkGetPackedB32(color), 28u);
|
||||
EXPECT_EQ(SkPMColorGetA(color), 255u);
|
||||
EXPECT_EQ(SkPMColorGetR(color), 232u);
|
||||
EXPECT_EQ(SkPMColorGetG(color), 5u);
|
||||
EXPECT_EQ(SkPMColorGetB(color), 28u);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -235,6 +235,7 @@ component("skia") {
|
||||
"ext/image_operations.h",
|
||||
"ext/legacy_display_globals.h",
|
||||
"ext/opacity_filter_canvas.h",
|
||||
"ext/pmcolor_utils.h",
|
||||
"ext/recursive_gaussian_convolution.h",
|
||||
"ext/rgba_to_yuva.h",
|
||||
"ext/skcolorspace_primaries.h",
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "base/time/time.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
#include "third_party/skia/include/core/SkTypes.h"
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "build/build_config.h"
|
||||
#include "skia/ext/convolver.h"
|
||||
#include "third_party/abseil-cpp/absl/container/inlined_vector.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
|
||||
namespace skia {
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkPixelRef.h"
|
||||
|
||||
// Native drawing context is only used/supported on Windows.
|
||||
@ -45,8 +44,7 @@ void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) {
|
||||
|
||||
bool IsOfColor(const SkBitmap& bitmap, int x, int y, uint32_t color) {
|
||||
// For masking out the alpha values.
|
||||
static uint32_t alpha_mask =
|
||||
static_cast<uint32_t>(SK_A32_MASK) << SK_A32_SHIFT;
|
||||
constexpr uint32_t alpha_mask = SkColorSetARGB(0xFF, 0, 0, 0);
|
||||
return (*bitmap.getAddr32(x, y) | alpha_mask) == (color | alpha_mask);
|
||||
}
|
||||
|
||||
|
52
skia/ext/pmcolor_utils.h
Normal file
52
skia/ext/pmcolor_utils.h
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2025 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SKIA_EXT_PMCOLOR_UTILS_H_
|
||||
#define SKIA_EXT_PMCOLOR_UTILS_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
|
||||
namespace skia {
|
||||
|
||||
// Interpret c as 4 x 8 bit channels and scale each of them by alpha/255
|
||||
// (approximately).
|
||||
inline uint32_t ScaleChannelsByAlpha(uint32_t c, unsigned alpha) {
|
||||
// approximate rgb * alpha / 255 with
|
||||
// rgb * (alpha + 1) / 256
|
||||
// because >> 8 is faster than / 255
|
||||
const unsigned scale = alpha + 1;
|
||||
|
||||
static constexpr uint32_t kMask = 0x00FF00FF;
|
||||
|
||||
// These variables imply that the passed in color is RGBA, but because
|
||||
// each channel is independent, it also works for BGRA.
|
||||
uint32_t rb = ((c & kMask) * scale) >> 8;
|
||||
uint32_t ag = ((c >> 8) & kMask) * scale;
|
||||
return (rb & kMask) | (ag & ~kMask);
|
||||
}
|
||||
|
||||
// Blend two premultiplied colors together
|
||||
inline SkPMColor BlendSrcOver(SkPMColor src, SkPMColor dst) {
|
||||
uint32_t scale = 256 - SkPMColorGetA(src);
|
||||
|
||||
static constexpr uint32_t kMask = 0x00FF00FF;
|
||||
uint32_t rb = (((dst & kMask) * scale) >> 8) & kMask;
|
||||
uint32_t ag = (((dst >> 8) & kMask) * scale) & ~kMask;
|
||||
|
||||
rb += (src & kMask);
|
||||
ag += (src & ~kMask);
|
||||
|
||||
// Color channels (but not alpha) can overflow, so we have to saturate to 0xFF
|
||||
// in each lane.
|
||||
return std::min(rb & 0x000001FF, 0x000000FFU) |
|
||||
std::min(ag & 0x0001FF00, 0x0000FF00U) |
|
||||
std::min(rb & 0x01FF0000, 0x00FF0000U) | (ag & 0xFF000000);
|
||||
}
|
||||
|
||||
} // namespace skia
|
||||
|
||||
#endif // SKIA_EXT_PMCOLOR_UTILS_H_
|
@ -17,6 +17,7 @@
|
||||
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/text/string_hasher.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -468,9 +469,15 @@ void TestUpdateRequiredPreviousFrameAfterFirstDecode(
|
||||
TestUpdateRequiredPreviousFrameAfterFirstDecode(create_decoder, data.get());
|
||||
}
|
||||
|
||||
static uint32_t PremultiplyColor(uint32_t c) {
|
||||
return SkPremultiplyARGBInline(SkGetPackedA32(c), SkGetPackedR32(c),
|
||||
SkGetPackedG32(c), SkGetPackedB32(c));
|
||||
// Takes in a pixel encoded as 8888 and returns it as a premultiplied
|
||||
// pixel encoded in Skia's N32 format.
|
||||
static SkPMColor PremultiplyColor(uint32_t pixel, SkColorType ct) {
|
||||
// If this assumption is false, then SkPreMultiplyARGB will return
|
||||
// a wrongly-encoded pixel.
|
||||
CHECK(ct == SkColorType::kN32_SkColorType);
|
||||
|
||||
return SkPreMultiplyARGB(SkPMColorGetA(pixel), SkPMColorGetR(pixel),
|
||||
SkPMColorGetG(pixel), SkPMColorGetB(pixel));
|
||||
}
|
||||
|
||||
static void VerifyFramesMatch(const char* file,
|
||||
@ -486,11 +493,11 @@ static void VerifyFramesMatch(const char* file,
|
||||
for (int x = 0; x < bitmap_a.width(); ++x) {
|
||||
uint32_t color_a = *bitmap_a.getAddr32(x, y);
|
||||
if (!a->PremultiplyAlpha()) {
|
||||
color_a = PremultiplyColor(color_a);
|
||||
color_a = PremultiplyColor(color_a, bitmap_a.colorType());
|
||||
}
|
||||
uint32_t color_b = *bitmap_b.getAddr32(x, y);
|
||||
if (!b->PremultiplyAlpha()) {
|
||||
color_b = PremultiplyColor(color_b);
|
||||
color_b = PremultiplyColor(color_b, bitmap_b.colorType());
|
||||
}
|
||||
uint8_t* pixel_a = reinterpret_cast<uint8_t*>(&color_a);
|
||||
uint8_t* pixel_b = reinterpret_cast<uint8_t*>(&color_b);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "ui/gfx/geometry/skia_conversions.h"
|
||||
|
||||
@ -229,25 +228,25 @@ static uint8_t BlendChannel(uint8_t src,
|
||||
}
|
||||
|
||||
static uint32_t BlendSrcOverDstNonPremultiplied(uint32_t src, uint32_t dst) {
|
||||
uint8_t src_a = SkGetPackedA32(src);
|
||||
uint8_t src_a = SkPMColorGetA(src);
|
||||
if (src_a == 0) {
|
||||
return dst;
|
||||
}
|
||||
|
||||
uint8_t dst_a = SkGetPackedA32(dst);
|
||||
uint8_t dst_factor_a = (dst_a * SkAlpha255To256(255 - src_a)) >> 8;
|
||||
uint8_t dst_a = SkPMColorGetA(dst);
|
||||
uint8_t dst_factor_a = (dst_a * (256 - src_a)) >> 8;
|
||||
DCHECK(src_a + dst_factor_a < (1U << 8));
|
||||
uint8_t blend_a = src_a + dst_factor_a;
|
||||
unsigned scale = (1UL << 24) / blend_a;
|
||||
|
||||
uint8_t blend_r = BlendChannel(SkGetPackedR32(src), src_a,
|
||||
SkGetPackedR32(dst), dst_factor_a, scale);
|
||||
uint8_t blend_g = BlendChannel(SkGetPackedG32(src), src_a,
|
||||
SkGetPackedG32(dst), dst_factor_a, scale);
|
||||
uint8_t blend_b = BlendChannel(SkGetPackedB32(src), src_a,
|
||||
SkGetPackedB32(dst), dst_factor_a, scale);
|
||||
uint8_t blend_r = BlendChannel(SkPMColorGetR(src), src_a, SkPMColorGetR(dst),
|
||||
dst_factor_a, scale);
|
||||
uint8_t blend_g = BlendChannel(SkPMColorGetG(src), src_a, SkPMColorGetG(dst),
|
||||
dst_factor_a, scale);
|
||||
uint8_t blend_b = BlendChannel(SkPMColorGetB(src), src_a, SkPMColorGetB(dst),
|
||||
dst_factor_a, scale);
|
||||
|
||||
return SkPackARGB32(blend_a, blend_r, blend_g, blend_b);
|
||||
return SkPMColorSetARGB(blend_a, blend_r, blend_g, blend_b);
|
||||
}
|
||||
|
||||
void ImageFrame::BlendRGBARaw(PixelData* dest,
|
||||
@ -255,7 +254,7 @@ void ImageFrame::BlendRGBARaw(PixelData* dest,
|
||||
unsigned g,
|
||||
unsigned b,
|
||||
unsigned a) {
|
||||
*dest = BlendSrcOverDstNonPremultiplied(SkPackARGB32(a, r, g, b), *dest);
|
||||
*dest = BlendSrcOverDstNonPremultiplied(SkPMColorSetARGB(a, r, g, b), *dest);
|
||||
}
|
||||
|
||||
void ImageFrame::BlendSrcOverDstRaw(PixelData* src, PixelData dst) {
|
||||
|
@ -38,11 +38,14 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/time/time.h"
|
||||
#include "skia/ext/pmcolor_utils.h"
|
||||
#include "third_party/blink/renderer/platform/platform_export.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
#include "third_party/skia/include/core/SkPixmap.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
class SkImage;
|
||||
@ -223,7 +226,7 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
if (premultiply_alpha_) {
|
||||
SetRGBAPremultiply(dest, r, g, b, a);
|
||||
} else {
|
||||
*dest = SkPackARGB32(a, r, g, b);
|
||||
*dest = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +244,7 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
b = (b * alpha + kRoundFractionControl) >> 16;
|
||||
}
|
||||
|
||||
*dest = SkPackARGB32(a, r, g, b);
|
||||
*dest = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
|
||||
static inline void SetRGBARaw(PixelData* dest,
|
||||
@ -249,7 +252,7 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
unsigned g,
|
||||
unsigned b,
|
||||
unsigned a) {
|
||||
*dest = SkPackARGB32(a, r, g, b);
|
||||
*dest = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
|
||||
// Blend the RGBA pixel provided by |red|, |green|, |blue| and |alpha| over
|
||||
@ -265,8 +268,9 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
PixelDataF16* src,
|
||||
size_t num_pixels);
|
||||
|
||||
// Blend the pixel, without premultiplication, in |src| over |dst| and
|
||||
// overwrite |src| with the result.
|
||||
// Blend the pixel in |src| over |dst| and overwrite |src| with the result.
|
||||
// This requires |src| and |dst| to not have alpha premultiplied on the rgb
|
||||
// channels.
|
||||
static void BlendSrcOverDstRaw(PixelData* src, PixelData dst);
|
||||
|
||||
// Blend the RGBA pixel provided by |r|, |g|, |b|, |a| over the pixel in
|
||||
@ -292,7 +296,7 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
|
||||
PixelData src;
|
||||
SetRGBAPremultiply(&src, r, g, b, a);
|
||||
*dest = SkPMSrcOver(src, *dest);
|
||||
*dest = skia::BlendSrcOver(src, *dest);
|
||||
}
|
||||
|
||||
static void BlendRGBAPremultipliedF16Buffer(PixelDataF16* dst,
|
||||
@ -300,9 +304,10 @@ class PLATFORM_EXPORT ImageFrame final {
|
||||
size_t num_pixels);
|
||||
|
||||
// Blend the pixel in |src| over |dst| and overwrite |src| with the result.
|
||||
// This requires |src| and |dst| to be premultiplied already.
|
||||
static inline void BlendSrcOverDstPremultiplied(PixelData* src,
|
||||
PixelData dst) {
|
||||
*src = SkPMSrcOver(*src, dst);
|
||||
*src = skia::BlendSrcOver(*src, dst);
|
||||
}
|
||||
|
||||
// Notifies the SkBitmap if any pixels changed and resets the flag.
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "third_party/blink/renderer/platform/image-decoders/image_frame.h"
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "third_party/skia/modules/skcms/skcms.h"
|
||||
|
||||
namespace blink {
|
||||
@ -28,8 +29,8 @@ class ImageFrameTest : public testing::Test {
|
||||
src_8888_r = 0x40;
|
||||
src_8888_g = 0x50;
|
||||
src_8888_b = 0x60;
|
||||
src_8888 = SkPackARGB32(src_8888_a, src_8888_r, src_8888_g, src_8888_b);
|
||||
dst_8888 = SkPackARGB32(0xA0, 0x60, 0x70, 0x80);
|
||||
src_8888 = SkPMColorSetARGB(src_8888_a, src_8888_r, src_8888_g, src_8888_b);
|
||||
dst_8888 = SkPMColorSetARGB(0xA0, 0x60, 0x70, 0x80);
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B, G, R, A)
|
||||
pixel_format_n32 = skcms_PixelFormat_BGRA_8888;
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/vector.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
#include "third_party/skia/include/core/SkImage.h"
|
||||
#include "third_party/skia/include/core/SkImageInfo.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
|
||||
// web_tests/images/resources/png-animated-idat-part-of-animation.png
|
||||
// is modified in multiple tests to simulate erroneous PNGs. As a reference,
|
||||
@ -1352,7 +1352,7 @@ TEST_P(StaticPNGTests, ColorType2TrnsBeforePlte) {
|
||||
// have alpha.
|
||||
EXPECT_FALSE(frame->HasAlpha());
|
||||
// The background is opaque green.
|
||||
EXPECT_EQ(*frame->GetAddr(1, 1), SkPackARGB32(0xFF, 0, 0xFF, 0));
|
||||
EXPECT_EQ(*frame->GetAddr(1, 1), SkPMColorSetARGB(0xFF, 0, 0xFF, 0));
|
||||
#else
|
||||
// If PNG_READ_OPT_PLTE_SUPPORTED is not defined, libpng performs only minimum
|
||||
// processing of an optional PLTE chunk. In particular, it doesn't check if
|
||||
@ -1361,7 +1361,7 @@ TEST_P(StaticPNGTests, ColorType2TrnsBeforePlte) {
|
||||
// and the frame should have alpha.
|
||||
EXPECT_TRUE(frame->HasAlpha());
|
||||
// The background is transparent green.
|
||||
EXPECT_EQ(*frame->GetAddr(1, 1), SkPackARGB32(0, 0, 0xFF, 0));
|
||||
EXPECT_EQ(*frame->GetAddr(1, 1), SkPMColorSetARGB(0, 0, 0xFF, 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ void alphaBlendPremultiplied(blink::ImageFrame& src,
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int canvasX = left + x;
|
||||
blink::ImageFrame::PixelData* pixel = src.GetAddr(canvasX, canvasY);
|
||||
if (SkGetPackedA32(*pixel) != 0xff) {
|
||||
if (SkPMColorGetA(*pixel) != 0xff) {
|
||||
blink::ImageFrame::PixelData prevPixel = *dst.GetAddr(canvasX, canvasY);
|
||||
blink::ImageFrame::BlendSrcOverDstPremultiplied(pixel, prevPixel);
|
||||
}
|
||||
@ -89,7 +89,7 @@ void alphaBlendNonPremultiplied(blink::ImageFrame& src,
|
||||
for (int x = 0; x < width; ++x) {
|
||||
int canvasX = left + x;
|
||||
blink::ImageFrame::PixelData* pixel = src.GetAddr(canvasX, canvasY);
|
||||
if (SkGetPackedA32(*pixel) != 0xff) {
|
||||
if (SkPMColorGetA(*pixel) != 0xff) {
|
||||
blink::ImageFrame::PixelData prevPixel = *dst.GetAddr(canvasX, canvasY);
|
||||
blink::ImageFrame::BlendSrcOverDstRaw(pixel, prevPixel);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "base/notreached.h"
|
||||
#include "third_party/skia/include/codec/SkJpegDecoder.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkImageInfo.h"
|
||||
#include "third_party/skia/include/encode/SkJpegEncoder.h"
|
||||
#include "ui/gfx/codec/vector_wstream.h"
|
||||
|
@ -15,8 +15,9 @@
|
||||
#include "skia/buildflags.h"
|
||||
#include "skia/rusty_png_feature.h"
|
||||
#include "third_party/skia/include/codec/SkPngDecoder.h"
|
||||
#include "third_party/skia/include/core/SkAlphaType.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkColorType.h"
|
||||
#include "third_party/skia/include/core/SkUnPreMultiply.h"
|
||||
#include "third_party/skia/include/encode/SkPngEncoder.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/libpng/png.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkUnPreMultiply.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "skia/ext/platform_canvas.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
#include "ui/gfx/color_palette.h"
|
||||
#include "ui/gfx/color_utils.h"
|
||||
|
@ -12,15 +12,17 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "skia/ext/pmcolor_utils.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColorFilter.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkUnPreMultiply.h"
|
||||
#include "third_party/skia/include/effects/SkImageFilters.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/gfx/geometry/insets.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
@ -118,9 +120,8 @@ SkBitmap SkBitmapOperations::CreateMaskedBitmap(const SkBitmap& rgb,
|
||||
uint32_t* dst_row = masked.getAddr32(0, y);
|
||||
|
||||
for (int x = 0; x < masked.width(); ++x) {
|
||||
unsigned alpha32 = SkGetPackedA32(alpha_row[x]);
|
||||
unsigned scale = SkAlpha255To256(alpha32);
|
||||
dst_row[x] = SkAlphaMulQ(rgb_row[x], scale);
|
||||
unsigned alpha32 = SkPMColorGetA(alpha_row[x]);
|
||||
dst_row[x] = skia::ScaleChannelsByAlpha(rgb_row[x], alpha32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,14 +264,14 @@ void LineProcHnopSnopLdec(const color_utils::HSL& hsl_shift,
|
||||
|
||||
uint32_t ldec_num = static_cast<uint32_t>(hsl_shift.l * 2 * den);
|
||||
for (int x = 0; x < width; x++) {
|
||||
uint32_t a = SkGetPackedA32(in[x]);
|
||||
uint32_t r = SkGetPackedR32(in[x]);
|
||||
uint32_t g = SkGetPackedG32(in[x]);
|
||||
uint32_t b = SkGetPackedB32(in[x]);
|
||||
uint32_t a = SkPMColorGetA(in[x]);
|
||||
uint32_t r = SkPMColorGetR(in[x]);
|
||||
uint32_t g = SkPMColorGetG(in[x]);
|
||||
uint32_t b = SkPMColorGetB(in[x]);
|
||||
r = r * ldec_num / den;
|
||||
g = g * ldec_num / den;
|
||||
b = b * ldec_num / den;
|
||||
out[x] = SkPackARGB32(a, r, g, b);
|
||||
out[x] = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,14 +288,14 @@ void LineProcHnopSnopLinc(const color_utils::HSL& hsl_shift,
|
||||
|
||||
uint32_t linc_num = static_cast<uint32_t>((hsl_shift.l - 0.5) * 2 * den);
|
||||
for (int x = 0; x < width; x++) {
|
||||
uint32_t a = SkGetPackedA32(in[x]);
|
||||
uint32_t r = SkGetPackedR32(in[x]);
|
||||
uint32_t g = SkGetPackedG32(in[x]);
|
||||
uint32_t b = SkGetPackedB32(in[x]);
|
||||
uint32_t a = SkPMColorGetA(in[x]);
|
||||
uint32_t r = SkPMColorGetR(in[x]);
|
||||
uint32_t g = SkPMColorGetG(in[x]);
|
||||
uint32_t b = SkPMColorGetB(in[x]);
|
||||
r += (a - r) * linc_num / den;
|
||||
g += (a - g) * linc_num / den;
|
||||
b += (a - b) * linc_num / den;
|
||||
out[x] = SkPackARGB32(a, r, g, b);
|
||||
out[x] = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,10 +334,10 @@ void LineProcHnopSdecLnop(const color_utils::HSL& hsl_shift,
|
||||
const int32_t denom = 65536;
|
||||
int32_t s_numer = static_cast<int32_t>(hsl_shift.s * 2 * denom);
|
||||
for (int x = 0; x < width; x++) {
|
||||
int32_t a = static_cast<int32_t>(SkGetPackedA32(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkGetPackedR32(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkGetPackedG32(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkGetPackedB32(in[x]));
|
||||
int32_t a = static_cast<int32_t>(SkPMColorGetA(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkPMColorGetR(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkPMColorGetG(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkPMColorGetB(in[x]));
|
||||
|
||||
int32_t vmax, vmin;
|
||||
if (r > g) { // This uses 3 compares rather than 4.
|
||||
@ -354,7 +355,7 @@ void LineProcHnopSdecLnop(const color_utils::HSL& hsl_shift,
|
||||
r = (denom_l + r * s_numer - s_numer_l) / denom;
|
||||
g = (denom_l + g * s_numer - s_numer_l) / denom;
|
||||
b = (denom_l + b * s_numer - s_numer_l) / denom;
|
||||
out[x] = SkPackARGB32(a, r, g, b);
|
||||
out[x] = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,10 +373,10 @@ void LineProcHnopSdecLdec(const color_utils::HSL& hsl_shift,
|
||||
int32_t l_numer = static_cast<int32_t>(hsl_shift.l * 2 * denom);
|
||||
int32_t s_numer = static_cast<int32_t>(hsl_shift.s * 2 * denom);
|
||||
for (int x = 0; x < width; x++) {
|
||||
int32_t a = static_cast<int32_t>(SkGetPackedA32(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkGetPackedR32(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkGetPackedG32(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkGetPackedB32(in[x]));
|
||||
int32_t a = static_cast<int32_t>(SkPMColorGetA(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkPMColorGetR(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkPMColorGetG(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkPMColorGetB(in[x]));
|
||||
|
||||
int32_t vmax, vmin;
|
||||
if (r > g) { // This uses 3 compares rather than 4.
|
||||
@ -393,7 +394,7 @@ void LineProcHnopSdecLdec(const color_utils::HSL& hsl_shift,
|
||||
r = (denom_l + r * s_numer - s_numer_l) * l_numer / (denom * denom);
|
||||
g = (denom_l + g * s_numer - s_numer_l) * l_numer / (denom * denom);
|
||||
b = (denom_l + b * s_numer - s_numer_l) * l_numer / (denom * denom);
|
||||
out[x] = SkPackARGB32(a, r, g, b);
|
||||
out[x] = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,10 +412,10 @@ void LineProcHnopSdecLinc(const color_utils::HSL& hsl_shift,
|
||||
int32_t l_numer = static_cast<int32_t>((hsl_shift.l - 0.5) * 2 * denom);
|
||||
int32_t s_numer = static_cast<int32_t>(hsl_shift.s * 2 * denom);
|
||||
for (int x = 0; x < width; x++) {
|
||||
int32_t a = static_cast<int32_t>(SkGetPackedA32(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkGetPackedR32(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkGetPackedG32(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkGetPackedB32(in[x]));
|
||||
int32_t a = static_cast<int32_t>(SkPMColorGetA(in[x]));
|
||||
int32_t r = static_cast<int32_t>(SkPMColorGetR(in[x]));
|
||||
int32_t g = static_cast<int32_t>(SkPMColorGetG(in[x]));
|
||||
int32_t b = static_cast<int32_t>(SkPMColorGetB(in[x]));
|
||||
|
||||
int32_t vmax, vmin;
|
||||
if (r > g) { // This uses 3 compares rather than 4.
|
||||
@ -436,7 +437,7 @@ void LineProcHnopSdecLinc(const color_utils::HSL& hsl_shift,
|
||||
r = (r * denom + (a * denom - r) * l_numer) / (denom * denom);
|
||||
g = (g * denom + (a * denom - g) * l_numer) / (denom * denom);
|
||||
b = (b * denom + (a * denom - b) * l_numer) / (denom * denom);
|
||||
out[x] = SkPackARGB32(a, r, g, b);
|
||||
out[x] = SkPMColorSetARGB(a, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
#include "third_party/skia/include/core/SkRegion.h"
|
||||
#include "third_party/skia/include/core/SkUnPreMultiply.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -166,7 +166,7 @@ TEST(SkBitmapOperationsTest, CreateMaskedBitmap) {
|
||||
alpha.allocN32Pixels(src_w, src_h);
|
||||
for (int y = 0, i = 0; y < src_h; y++) {
|
||||
for (int x = 0; x < src_w; x++) {
|
||||
*alpha.getAddr32(x, y) = SkPackARGB32(i % 256, 0, 0, 0);
|
||||
*alpha.getAddr32(x, y) = SkPMColorSetARGB(i % 256, 0, 0, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -175,26 +175,21 @@ TEST(SkBitmapOperationsTest, CreateMaskedBitmap) {
|
||||
|
||||
for (int y = 0; y < src_h; y++) {
|
||||
for (int x = 0; x < src_w; x++) {
|
||||
int alpha_pixel = *alpha.getAddr32(x, y);
|
||||
int src_pixel = *src.getAddr32(x, y);
|
||||
int masked_pixel = *masked.getAddr32(x, y);
|
||||
const SkPMColor alpha_pixel = *alpha.getAddr32(x, y);
|
||||
const SkPMColor src_pixel = *src.getAddr32(x, y);
|
||||
const SkPMColor masked_pixel = *masked.getAddr32(x, y);
|
||||
|
||||
int scale = SkAlpha255To256(SkGetPackedA32(alpha_pixel));
|
||||
// Check that the src * alpha / 255 was approximated as
|
||||
// src * (alpha + 1) / 256
|
||||
// across all 4 channels
|
||||
const unsigned scale = SkPMColorGetA(alpha_pixel) + 1;
|
||||
|
||||
int src_a = (src_pixel >> SK_A32_SHIFT) & 0xFF;
|
||||
int src_r = (src_pixel >> SK_R32_SHIFT) & 0xFF;
|
||||
int src_g = (src_pixel >> SK_G32_SHIFT) & 0xFF;
|
||||
int src_b = (src_pixel >> SK_B32_SHIFT) & 0xFF;
|
||||
for (unsigned shift = 0; shift < 32; shift += 8) {
|
||||
const unsigned s = (src_pixel >> shift) & 0xFF;
|
||||
const unsigned m = (masked_pixel >> shift) & 0xFF;
|
||||
|
||||
int masked_a = (masked_pixel >> SK_A32_SHIFT) & 0xFF;
|
||||
int masked_r = (masked_pixel >> SK_R32_SHIFT) & 0xFF;
|
||||
int masked_g = (masked_pixel >> SK_G32_SHIFT) & 0xFF;
|
||||
int masked_b = (masked_pixel >> SK_B32_SHIFT) & 0xFF;
|
||||
|
||||
EXPECT_EQ((src_a * scale) >> 8, masked_a);
|
||||
EXPECT_EQ((src_r * scale) >> 8, masked_r);
|
||||
EXPECT_EQ((src_g * scale) >> 8, masked_g);
|
||||
EXPECT_EQ((src_b * scale) >> 8, masked_b);
|
||||
EXPECT_EQ((s * scale) >> 8, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -445,10 +440,10 @@ TEST(SkBitmapOperationsTest, UnPreMultiply) {
|
||||
EXPECT_EQ(input.alphaType(), kPremul_SkAlphaType);
|
||||
|
||||
// Set PMColors into the bitmap
|
||||
*input.getAddr32(0, 0) = SkPackARGB32(0x80, 0x00, 0x00, 0x00);
|
||||
*input.getAddr32(1, 0) = SkPackARGB32(0x80, 0x80, 0x80, 0x80);
|
||||
*input.getAddr32(0, 1) = SkPackARGB32(0xFF, 0x00, 0xCC, 0x88);
|
||||
*input.getAddr32(1, 1) = SkPackARGB32(0x00, 0x00, 0xCC, 0x88);
|
||||
*input.getAddr32(0, 0) = SkPMColorSetARGB(0x80, 0x00, 0x00, 0x00);
|
||||
*input.getAddr32(1, 0) = SkPMColorSetARGB(0x80, 0x80, 0x80, 0x80);
|
||||
*input.getAddr32(0, 1) = SkPMColorSetARGB(0xFF, 0x00, 0xCC, 0x88);
|
||||
*input.getAddr32(1, 1) = SkPMColorSetARGB(0x00, 0x00, 0xCC, 0x88);
|
||||
|
||||
SkBitmap result = SkBitmapOperations::UnPreMultiply(input);
|
||||
EXPECT_EQ(result.alphaType(), kUnpremul_SkAlphaType);
|
||||
|
@ -39,11 +39,11 @@
|
||||
#include "skia/ext/skia_utils_win.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkColorPriv.h"
|
||||
#include "third_party/skia/include/core/SkPath.h"
|
||||
#include "third_party/skia/include/core/SkRefCnt.h"
|
||||
#include "third_party/skia/include/core/SkShader.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
#include "third_party/skia/include/private/chromium/SkPMColor.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "ui/color/color_provider.h"
|
||||
@ -849,12 +849,12 @@ void NativeThemeWin::PaintIndirect(cc::PaintCanvas* destination_canvas,
|
||||
for (int i = 0; i < pixel_count; i++) {
|
||||
if (pixels[i] == placeholder_value) {
|
||||
// Pixel wasn't touched - make it fully transparent.
|
||||
pixels[i] = SkPackARGB32(0, 0, 0, 0);
|
||||
} else if (SkGetPackedA32(pixels[i]) == 0) {
|
||||
pixels[i] = SkPMColorSetARGB(0, 0, 0, 0);
|
||||
} else if (SkPMColorGetA(pixels[i]) == 0) {
|
||||
// Pixel was touched but has incorrect alpha of 0, make it fully opaque.
|
||||
pixels[i] =
|
||||
SkPackARGB32(0xFF, SkGetPackedR32(pixels[i]),
|
||||
SkGetPackedG32(pixels[i]), SkGetPackedB32(pixels[i]));
|
||||
SkPMColorSetARGB(0xFF, SkPMColorGetR(pixels[i]),
|
||||
SkPMColorGetG(pixels[i]), SkPMColorGetB(pixels[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user