blob: d9ffc77c1279a007f99760d40f345973478354b7 [file] [log] [blame]
rileya@google.com589708b2012-07-26 20:04:23 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkLinearGradient_DEFINED
9#define SkLinearGradient_DEFINED
10
11#include "SkGradientShaderPriv.h"
12
13class SkLinearGradient : public SkGradientShaderBase {
14public:
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +000015 SkLinearGradient(const SkPoint pts[2], const Descriptor&, const SkMatrix* localMatrix);
rileya@google.com589708b2012-07-26 20:04:23 +000016
commit-bot@chromium.orge901b6d2014-05-01 19:31:31 +000017 virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE;
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000018 virtual size_t contextSize() const SK_OVERRIDE;
19
20 class LinearGradientContext : public SkGradientShaderBase::GradientShaderBaseContext {
21 public:
commit-bot@chromium.orge901b6d2014-05-01 19:31:31 +000022 LinearGradientContext(const SkLinearGradient&, const ContextRec&);
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000023 ~LinearGradientContext() {}
24
25 virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) SK_OVERRIDE;
26 virtual void shadeSpan16(int x, int y, uint16_t dstC[], int count) SK_OVERRIDE;
27
28 private:
29 typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED;
30 };
31
rileya@google.com589708b2012-07-26 20:04:23 +000032 virtual BitmapType asABitmap(SkBitmap*, SkMatrix*, TileMode*) const SK_OVERRIDE;
33 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
bsalomon@google.com0ac6af42013-01-16 15:16:18 +000034 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
rileya@google.com589708b2012-07-26 20:04:23 +000035
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000036 SK_TO_STRING_OVERRIDE()
rileya@google.com589708b2012-07-26 20:04:23 +000037 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLinearGradient)
38
39protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000040 SkLinearGradient(SkReadBuffer& buffer);
41 virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE;
rileya@google.com589708b2012-07-26 20:04:23 +000042
43private:
44 typedef SkGradientShaderBase INHERITED;
45 const SkPoint fStart;
46 const SkPoint fEnd;
47};
48
rileya@google.com589708b2012-07-26 20:04:23 +000049#endif