This commit is contained in:
Adam Barth
2016-10-20 13:23:09 -07:00
committed by GitHub
parent c19eca2eb9
commit a4f6c12e73
9 changed files with 22 additions and 23 deletions

2
DEPS
View File

@@ -23,7 +23,7 @@ vars = {
'github_git': 'https://github.com',
'mojo_sdk_revision': '6b5fb1227c742f5ecc077486ebc029f2711c61fa',
'base_revision': 'b2412302ed4e45bfb47d7b5c0c3418077009e1ce',
'skia_revision': 'e038489a743d6c0ab1cb208862c305180815bc8e',
'skia_revision': 'bbe17a66705aff6f34a22adc0c12883dcb6161b3',
# Note: When updating the Dart revision, ensure that all entries that are
# dependencies of dart are also updated

View File

@@ -13,7 +13,7 @@ ColorFilterLayer::~ColorFilterLayer() {}
void ColorFilterLayer::Paint(PaintContext& context) {
TRACE_EVENT0("flutter", "ColorFilterLayer::Paint");
sk_sp<SkColorFilter> color_filter =
SkColorFilter::MakeModeFilter(color_, transfer_mode_);
SkColorFilter::MakeModeFilter(color_, blend_mode_);
SkPaint paint;
paint.setColorFilter(std::move(color_filter));

View File

@@ -16,16 +16,14 @@ class ColorFilterLayer : public ContainerLayer {
void set_color(SkColor color) { color_ = color; }
void set_transfer_mode(SkXfermode::Mode transfer_mode) {
transfer_mode_ = transfer_mode;
}
void set_blend_mode(SkBlendMode blend_mode) { blend_mode_ = blend_mode; }
protected:
void Paint(PaintContext& context) override;
private:
SkColor color_;
SkXfermode::Mode transfer_mode_;
SkBlendMode blend_mode_;
FTL_DISALLOW_COPY_AND_ASSIGN(ColorFilterLayer);
};

View File

@@ -17,7 +17,7 @@ void ShaderMaskLayer::Paint(PaintContext& context) {
PaintChildren(context);
SkPaint paint;
paint.setXfermodeMode(transfer_mode_);
paint.setBlendMode(blend_mode_);
paint.setShader(shader_);
context.canvas.translate(mask_rect_.left(), mask_rect_.top());
context.canvas.drawRect(

View File

@@ -20,8 +20,8 @@ class ShaderMaskLayer : public ContainerLayer {
void set_mask_rect(const SkRect& mask_rect) { mask_rect_ = mask_rect; }
void set_transfer_mode(SkXfermode::Mode transfer_mode) {
transfer_mode_ = transfer_mode;
void set_blend_mode(SkBlendMode blend_mode) {
blend_mode_ = blend_mode;
}
protected:
@@ -30,7 +30,7 @@ class ShaderMaskLayer : public ContainerLayer {
private:
sk_sp<SkShader> shader_;
SkRect mask_rect_;
SkXfermode::Mode transfer_mode_;
SkBlendMode blend_mode_;
FTL_DISALLOW_COPY_AND_ASSIGN(ShaderMaskLayer);
};

View File

@@ -18,9 +18,9 @@
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/painting/shader.h"
#include "lib/ftl/build_config.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_args.h"
#include "lib/tonic/dart_binding_macros.h"
#include "lib/tonic/converter/dart_converter.h"
#include "lib/tonic/dart_library_natives.h"
#include "third_party/skia/include/core/SkColorFilter.h"
@@ -121,10 +121,10 @@ void SceneBuilder::pushOpacity(int alpha) {
addLayer(std::move(layer), m_cullRects.top());
}
void SceneBuilder::pushColorFilter(int color, int transferMode) {
void SceneBuilder::pushColorFilter(int color, int blendMode) {
std::unique_ptr<flow::ColorFilterLayer> layer(new flow::ColorFilterLayer());
layer->set_color(static_cast<SkColor>(color));
layer->set_transfer_mode(static_cast<SkXfermode::Mode>(transferMode));
layer->set_blend_mode(static_cast<SkBlendMode>(blendMode));
addLayer(std::move(layer), m_cullRects.top());
}
@@ -140,12 +140,12 @@ void SceneBuilder::pushShaderMask(Shader* shader,
double maskRectRight,
double maskRectTop,
double maskRectBottom,
int transferMode) {
int blendMode) {
std::unique_ptr<flow::ShaderMaskLayer> layer(new flow::ShaderMaskLayer());
layer->set_shader(shader->shader());
layer->set_mask_rect(SkRect::MakeLTRB(maskRectLeft, maskRectTop,
maskRectRight, maskRectBottom));
layer->set_transfer_mode(static_cast<SkXfermode::Mode>(transferMode));
layer->set_blend_mode(static_cast<SkBlendMode>(blendMode));
addLayer(std::move(layer), m_cullRects.top());
}

View File

@@ -171,10 +171,10 @@ void Canvas::clipPath(const CanvasPath* path) {
canvas_->clipPath(path->path(), true);
}
void Canvas::drawColor(SkColor color, SkXfermode::Mode transfer_mode) {
void Canvas::drawColor(SkColor color, SkBlendMode blend_mode) {
if (!canvas_)
return;
canvas_->drawColor(color, transfer_mode);
canvas_->drawColor(color, blend_mode);
}
void Canvas::drawLine(double x1,

View File

@@ -68,7 +68,7 @@ class Canvas : public ftl::RefCountedThreadSafe<Canvas>,
void clipRRect(const RRect& rrect);
void clipPath(const CanvasPath* path);
void drawColor(SkColor color, SkXfermode::Mode transfer_mode);
void drawColor(SkColor color, SkBlendMode blend_mode);
void drawLine(double x1,
double y1,
double x2,

View File

@@ -19,7 +19,7 @@ namespace tonic {
constexpr int kIsAntiAliasIndex = 0;
constexpr int kColorIndex = 1;
constexpr int kTransferModeIndex = 2;
constexpr int kBlendModeIndex = 2;
constexpr int kStyleIndex = 3;
constexpr int kStrokeWidthIndex = 4;
constexpr int kStrokeCapIndex = 5;
@@ -82,10 +82,11 @@ Paint DartConverter<Paint>::FromArguments(Dart_NativeArguments args,
paint.setColor(color);
}
uint32_t encoded_transfer_mode = uint_data[kTransferModeIndex];
if (encoded_transfer_mode) {
uint32_t transfer_mode = encoded_transfer_mode ^ SkXfermode::kSrcOver_Mode;
paint.setXfermodeMode(static_cast<SkXfermode::Mode>(transfer_mode));
uint32_t encoded_blend_mode = uint_data[kBlendModeIndex];
if (encoded_blend_mode) {
uint32_t transfer_mode =
encoded_blend_mode ^ static_cast<uint32_t>(SkBlendMode::kSrcOver);
paint.setBlendMode(static_cast<SkBlendMode>(transfer_mode));
}
uint32_t style = uint_data[kStyleIndex];