summaryrefslogtreecommitdiffstats
path: root/gfx/angle/checkout/src/libANGLE/Path.cpp
blob: 86adae743f869b23066f8fbab5e534f34da7ca82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Copyright (c) 2002-2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// Path.h: Defines the gl::Path class, representing CHROMIUM_path_rendering
// path object.

#include "libANGLE/Path.h"
#include "libANGLE/renderer/PathImpl.h"

#include "common/debug.h"
#include "common/mathutil.h"

namespace gl
{

Path::Path(rx::PathImpl *impl)
    : mPath(impl),
      mHasData(false),
      mEndCaps(GL_FLAT_CHROMIUM),
      mJoinStyle(GL_MITER_REVERT_CHROMIUM),
      mStrokeWidth(1.0f),
      mStrokeBound(0.2f),
      mMiterLimit(4.0f)
{}

Path::~Path()
{
    delete mPath;
}

angle::Result Path::setCommands(GLsizei numCommands,
                                const GLubyte *commands,
                                GLsizei numCoords,
                                GLenum coordType,
                                const void *coords)
{
    ANGLE_TRY(mPath->setCommands(numCommands, commands, numCoords, coordType, coords));

    mHasData = true;

    return angle::Result::Continue;
}

void Path::setStrokeWidth(GLfloat width)
{
    mStrokeWidth = width;
    mPath->setPathParameter(GL_PATH_STROKE_WIDTH_CHROMIUM, mStrokeWidth);
}

void Path::setStrokeBound(GLfloat bound)
{
    mStrokeBound = clamp(bound, 0.0f, 1.0f);
    mPath->setPathParameter(GL_PATH_STROKE_BOUND_CHROMIUM, mStrokeBound);
}

void Path::setEndCaps(GLenum type)
{
    mEndCaps = type;
    mPath->setPathParameter(GL_PATH_END_CAPS_CHROMIUM, static_cast<GLfloat>(type));
}

void Path::setJoinStyle(GLenum type)
{
    mJoinStyle = type;
    mPath->setPathParameter(GL_PATH_JOIN_STYLE_CHROMIUM, static_cast<GLfloat>(type));
}

void Path::setMiterLimit(GLfloat value)
{
    mMiterLimit = value;
    mPath->setPathParameter(GL_PATH_MITER_LIMIT_CHROMIUM, value);
}

}  // namespace gl