Matt Perry edd0d6e16a Add support for linear gradients, implemented as skia shaders.
I had to complicate the IDL bindings generation to allow passing an array of
colors. Without these changes, we'd try to convert the dart object to
Vector<SkColor>, which C++ thinks is Vector<unsigned>, and we'd use the wrong
converter. So I added some template grease to force it to use a
Vector<CanvasColor> converter.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1152963009
2015-06-08 13:49:10 -04:00

44 lines
1.2 KiB
C++

// 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 "sky/engine/config.h"
#include "sky/engine/core/painting/Point.h"
#include "sky/engine/core/script/dom_dart_state.h"
#include "sky/engine/tonic/dart_error.h"
#include "base/logging.h"
namespace blink {
// Convert handle.x,y ==> SkPoint.
Point DartConverter<Point>::FromDart(Dart_Handle handle) {
Point result;
result.is_null = true;
DCHECK(!LogIfError(handle));
Dart_Handle x_value =
Dart_GetField(handle, DOMDartState::Current()->x_handle());
Dart_Handle y_value =
Dart_GetField(handle, DOMDartState::Current()->y_handle());
double x = 0.0, y = 0.0;
Dart_Handle err = Dart_DoubleValue(x_value, &x);
DCHECK(!LogIfError(err));
err = Dart_DoubleValue(y_value, &y);
DCHECK(!LogIfError(err));
result.sk_point.set(x, y);
result.is_null = false;
return result;
}
Point DartConverter<Point>::FromArgumentsWithNullCheck(
Dart_NativeArguments args,
int index,
Dart_Handle& exception) {
return FromDart(Dart_GetNativeArgument(args, index));
}
} // namespace blink