Sami Väisänen | e45e53b | 2016-05-25 10:36:04 +0300 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (c) 2002-2016 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // Path.h: Defines the gl::Path class, representing CHROMIUM_path_rendering |
| 8 | // path object. |
| 9 | |
| 10 | #include "libANGLE/Path.h" |
| 11 | #include "libANGLE/renderer/PathImpl.h" |
| 12 | |
| 13 | #include "common/mathutil.h" |
| 14 | #include "common/debug.h" |
| 15 | |
| 16 | namespace gl |
| 17 | { |
| 18 | |
| 19 | Path::Path(rx::PathImpl *impl) |
| 20 | : mPath(impl), |
| 21 | mHasData(false), |
| 22 | mEndCaps(GL_FLAT_CHROMIUM), |
| 23 | mJoinStyle(GL_MITER_REVERT_CHROMIUM), |
| 24 | mStrokeWidth(1.0f), |
| 25 | mStrokeBound(0.2f), |
| 26 | mMiterLimit(4.0f) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | Path::~Path() |
| 31 | { |
| 32 | delete mPath; |
| 33 | } |
| 34 | |
| 35 | Error Path::setCommands(GLsizei numCommands, |
| 36 | const GLubyte *commands, |
| 37 | GLsizei numCoords, |
| 38 | GLenum coordType, |
| 39 | const void *coords) |
| 40 | { |
| 41 | ANGLE_TRY(mPath->setCommands(numCommands, commands, numCoords, coordType, coords)); |
| 42 | |
| 43 | mHasData = true; |
| 44 | |
| 45 | return gl::NoError(); |
| 46 | } |
| 47 | |
| 48 | void Path::setStrokeWidth(GLfloat width) |
| 49 | { |
| 50 | mStrokeWidth = width; |
| 51 | mPath->setPathParameter(GL_PATH_STROKE_WIDTH_CHROMIUM, mStrokeWidth); |
| 52 | } |
| 53 | |
| 54 | void Path::setStrokeBound(GLfloat bound) |
| 55 | { |
| 56 | mStrokeBound = clamp(bound, 0.0f, 1.0f); |
| 57 | mPath->setPathParameter(GL_PATH_STROKE_BOUND_CHROMIUM, mStrokeBound); |
| 58 | } |
| 59 | |
| 60 | void Path::setEndCaps(GLenum type) |
| 61 | { |
| 62 | mEndCaps = type; |
| 63 | mPath->setPathParameter(GL_PATH_END_CAPS_CHROMIUM, static_cast<GLfloat>(type)); |
| 64 | } |
| 65 | |
| 66 | void Path::setJoinStyle(GLenum type) |
| 67 | { |
| 68 | mJoinStyle = type; |
| 69 | mPath->setPathParameter(GL_PATH_JOIN_STYLE_CHROMIUM, static_cast<GLfloat>(type)); |
| 70 | } |
| 71 | |
| 72 | void Path::setMiterLimit(GLfloat value) |
| 73 | { |
| 74 | mMiterLimit = value; |
| 75 | mPath->setPathParameter(GL_PATH_MITER_LIMIT_CHROMIUM, value); |
| 76 | } |
| 77 | |
| 78 | } // gl |