Пример #1
0
void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
                                              const GrDrawEffect& drawEffect,
                                              int effectIdx) {
    uint32_t totalKey = fTransforms[effectIdx].fTransformKey;
    int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
    int numTransforms = drawEffect.effect()->numTransforms();
    for (int t = 0; t < numTransforms; ++t) {
        switch (get_matrix_type(totalKey, t)) {
            case kNoPersp_MatrixType: {
                const SkMatrix& transform = get_transform_matrix(drawEffect, t);
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kST_PathTexGenComponents,
                                      transform);
                break;
            }
            case kGeneral_MatrixType: {
                const SkMatrix& transform = get_transform_matrix(drawEffect, t);
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kSTR_PathTexGenComponents,
                                      transform);
                break;
            }
            default:
                SkFAIL("Unexpected matrixs type.");
        }
    }
}
Пример #2
0
static int lauem3m( int axes[3],
		    const Symmetry * symmetry )
{
  int i, count, axis, tmpval;
  int prop_rot[3][3], t_mat[3][3];

  for ( i = 0; i < 3; i++ ) { axes[i] = -1; }
  count = 0;
  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search four-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot ) == 1 ) ) {
      continue;
    }

    axis = get_rotation_axis( prop_rot );
    if ( ! ( ( axis == axes[0] ) ||
	     ( axis == axes[1] ) ||
	     ( axis == axes[2] ) ) ) {
      axes[count] = axis;
      count++;
    }
  }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;
}
Пример #3
0
static int laue4m( int axes[3],
		   const Symmetry * symmetry )
{
  int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
  int axis_vec[3];
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search foud-fold rotation */
    if (  mat_get_trace_i3( prop_rot ) == 1 ) {
      /* The first axis */
      axes[2] = get_rotation_axis( prop_rot );
      break;
    }
  }

  /* The second axis */
  num_ortho_axis = get_orthogonal_axis( ortho_axes, prop_rot, 4 );
  if ( ! num_ortho_axis ) { goto err; }
  
  min_norm = 8;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    norm = mat_norm_squared_i3( rot_axes[ortho_axes[i]] );
    if ( norm < min_norm ) {
      min_norm = norm;
      axes[0] = ortho_axes[i];
      is_found = 1;
    }
  }
  if ( ! is_found ) { goto err; }
  
  /* The third axis */
  mat_multiply_matrix_vector_i3( axis_vec, prop_rot, rot_axes[axes[0]] );
  is_found = 0;
  for ( i = 0; i < NUM_ROT_AXES; i++ ) {
    if ( is_exist_axis( axis_vec, i ) ) {
      is_found = 1;
      axes[1] = i;
      break;
    }
  }
  if ( ! is_found ) { goto err; }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Пример #4
0
void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
                                              const GrDrawEffect& drawEffect,
                                              int effectIdx) {
    EffectKey totalKey = fTransforms[effectIdx].fTransformKey;
    int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
    int numTransforms = (*drawEffect.effect())->numTransforms();
    for (int t = 0; t < numTransforms; ++t) {
        switch (get_matrix_type(totalKey, t)) {
            case kIdentity_MatrixType: {
                SkASSERT(get_transform_matrix(drawEffect, t).isIdentity());
                GrGLfloat identity[] = {1, 0, 0,
                                        0, 1, 0};
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kST_PathTexGenComponents,
                                      identity);
                break;
            }
            case kTrans_MatrixType: {
                GrGLfloat tx, ty;
                get_transform_translation(drawEffect, t, &tx, &ty);
                GrGLfloat translate[] = {1, 0, tx,
                                         0, 1, ty};
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kST_PathTexGenComponents,
                                      translate);
                break;
            }
            case kNoPersp_MatrixType: {
                const SkMatrix& transform = get_transform_matrix(drawEffect, t);
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kST_PathTexGenComponents,
                                      transform);
                break;
            }
            case kGeneral_MatrixType: {
                const SkMatrix& transform = get_transform_matrix(drawEffect, t);
                gpu->enablePathTexGen(texCoordIndex++,
                                      GrGpuGL::kSTR_PathTexGenComponents,
                                      transform);
                break;
            }
            default:
                SkFAIL("Unexpected matrixs type.");
        }
    }
}
Пример #5
0
/* pointgroup is modified. */
void ptg_get_transformation_matrix( Pointgroup * pointgroup,
				    const Symmetry * symmetry )
{
  int axes[3];
  int transform_mat[3][3];

  get_axes( axes, pointgroup->laue, symmetry );
  get_transform_matrix( transform_mat, axes );
  mat_copy_matrix_i3( pointgroup->transform_mat, transform_mat );
}
Пример #6
0
	glm::vec4 Decal::get_decal_rect() const
	{
		glm::vec2 min, max, tmp;

		tmp = glm::vec3(-1.0f, -1.0f, 1.0f) * get_transform_matrix();
		min = tmp;
		max = tmp;

		tmp = glm::vec3( 1.0f, -1.0f, 1.0f) * get_transform_matrix();
		min = glm::min(min, tmp);
		max = glm::max(max, tmp);

		tmp = glm::vec3(-1.0f,  1.0f, 1.0f) * get_transform_matrix();
		min = glm::min(min, tmp);
		max = glm::max(max, tmp);

		tmp = glm::vec3( 1.0f,  1.0f, 1.0f) * get_transform_matrix();
		min = glm::min(min, tmp);
		max = glm::max(max, tmp);

		return glm::vec4(min, max);
	}
Пример #7
0
void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor,
                                   GrGLInstalledFragProc* ip) {
    SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransforms;
    int numTransforms = transforms.count();
    SkASSERT(numTransforms == processor.getProcessor()->numTransforms());
    for (int t = 0; t < numTransforms; ++t) {
        SkASSERT(transforms[t].fHandle.isValid());
        const SkMatrix& matrix = get_transform_matrix(processor, ip->fLocalCoordAttrib, t);
        if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
            fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUniformHandle(), matrix);
            transforms[t].fCurrentValue = matrix;
        }
    }
}
Пример #8
0
void GrGLVertexProgramEffects::setTransformData(const GrGLProgramDataManager& programResourceManager,
                                                const GrDrawEffect& drawEffect,
                                                int effectIdx) {
    SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
    int numTransforms = transforms.count();
    SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
    for (int t = 0; t < numTransforms; ++t) {
        SkASSERT(transforms[t].fHandle.isValid());
        const SkMatrix& matrix = get_transform_matrix(drawEffect, t);
        if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
            programResourceManager.setSkMatrix(transforms[t].fHandle, matrix);
            transforms[t].fCurrentValue = matrix;
        }
    }
}
Пример #9
0
void GrGLVertexProgramEffects::setTransformData(const GrGLUniformManager& uniformManager,
                                                const GrDrawEffect& drawEffect,
                                                int effectIdx) {
    SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
    int numTransforms = transforms.count();
    SkASSERT(numTransforms == (*drawEffect.effect())->numTransforms());
    for (int t = 0; t < numTransforms; ++t) {
        SkASSERT(transforms[t].fHandle.isValid() != (kVoid_GrSLType == transforms[t].fType));
        switch (transforms[t].fType) {
            case kVoid_GrSLType:
                SkASSERT(get_transform_matrix(drawEffect, t).isIdentity());
                break;
            case kVec2f_GrSLType: {
                GrGLfloat tx, ty;
                get_transform_translation(drawEffect, t, &tx, &ty);
                if (transforms[t].fCurrentValue.get(SkMatrix::kMTransX) != tx ||
                    transforms[t].fCurrentValue.get(SkMatrix::kMTransY) != ty) {
                    uniformManager.set2f(transforms[t].fHandle, tx, ty);
                    transforms[t].fCurrentValue.set(SkMatrix::kMTransX, tx);
                    transforms[t].fCurrentValue.set(SkMatrix::kMTransY, ty);
                }
                break;
            }
            case kMat33f_GrSLType: {
                const SkMatrix& matrix = get_transform_matrix(drawEffect, t);
                if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
                    uniformManager.setSkMatrix(transforms[t].fHandle, matrix);
                    transforms[t].fCurrentValue = matrix;
                }
                break;
            }
            default:
                SkFAIL("Unexpected uniform type.");
        }
    }
}
Пример #10
0
static int laue_one_axis( int axes[3],
			  const Symmetry * symmetry,
			  const int rot_order )
{
  int i, j, num_ortho_axis, det, min_det, is_found, tmpval;
  int axis_vec[3], tmp_axes[3];
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search foud-fold rotation */
    if ( rot_order == 4 ) {
      if (  mat_get_trace_i3( prop_rot ) == 1 ) {
	/* The first axis */
	axes[2] = get_rotation_axis( prop_rot );
	break;
      }
    }

    /* Search three-fold rotation */
    if ( rot_order == 3 ) {
      if (  mat_get_trace_i3( prop_rot ) == 0 ) {
	/* The first axis */
	axes[2] = get_rotation_axis( prop_rot );
	break;
      }
    }
  }

  /* Candidates of the second axis */
  num_ortho_axis = get_orthogonal_axis( ortho_axes, prop_rot, rot_order );
  if ( ! num_ortho_axis ) { goto err; }

  tmp_axes[2] = axes[2];
  min_det = 4;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    tmp_axes[0] = ortho_axes[i];
    mat_multiply_matrix_vector_i3( axis_vec, prop_rot,
				   rot_axes[tmp_axes[0]] );
    for ( j = 0; j < num_ortho_axis; j++ ) {
      is_found = is_exist_axis( axis_vec, ortho_axes[j] );
      if ( is_found == 1 ) {
	tmp_axes[1] = ortho_axes[j];
	break;
      }
      if ( is_found == -1 ) {
	tmp_axes[1] = ortho_axes[j] + NUM_ROT_AXES;
	break;
      }
    }

    get_transform_matrix( t_mat, tmp_axes );
    det = mat_get_determinant_i3( t_mat );
    if ( det < 0 ) { det = -det; }
    if ( det < min_det ) {
      min_det = det;
      axes[0] = tmp_axes[0];
      axes[1] = tmp_axes[1];
    }
  }
  if ( ! is_found ) { goto err; }
  
  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Пример #11
0
static int laue3m( int axes[3],
		   const Symmetry * symmetry )
{
  int i, is_found, tmpval, axis;
  int prop_rot[3][3], prop_rot2[3][3], t_mat[3][3];
  int axis_vec[3];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search three-fold rotation */
    if ( mat_get_trace_i3( prop_rot ) == 0 ) {
      /* The first axis */
      axes[2] = get_rotation_axis( prop_rot );
      debug_print("laue3m prop_rot\n");
      debug_print_matrix_i3( prop_rot );
      break;
    }
  }

  is_found = 0;
  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot2, symmetry->rot[i] );

    /* Search two-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot2 ) == -1 ) ) {
      continue;
    }

    /* The second axis */
    axis = get_rotation_axis( prop_rot2 );
    if ( ! ( axis == axes[2] ) ) {
      axes[0] = axis;
      is_found = 1;
      break;
    }
  }
  if ( ! is_found ) { goto err; }

  /* The third axis */
  mat_multiply_matrix_vector_i3( axis_vec, prop_rot, rot_axes[axes[0]] );
  is_found = 0;
  for ( i = 0; i < NUM_ROT_AXES; i++ ) {
    is_found = is_exist_axis( axis_vec, i );
    if ( is_found == 1 ) {
      axes[1] = i;
      break;
    }
    if ( is_found == -1 ) {
      axes[1] = i + NUM_ROT_AXES;
      break;
    }
  }
  if ( ! is_found ) { goto err; }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[1];
    axes[1] = tmpval;
  }

  return 1;

 err:
  return 0;
}
Пример #12
0
static int laue2m( int axes[3],
		   const Symmetry * symmetry )
{
  int i, num_ortho_axis, norm, min_norm, is_found, tmpval;
  int prop_rot[3][3], t_mat[3][3];
  int ortho_axes[NUM_ROT_AXES];

  for ( i = 0; i < symmetry->size; i++ ) {
    get_proper_rotation( prop_rot, symmetry->rot[i] );

    /* Search two-fold rotation */
    if ( ! ( mat_get_trace_i3( prop_rot ) == -1 ) ) {
      continue;
    }

    /* The first axis */
    axes[1] = get_rotation_axis( prop_rot );
    break;
  }

  /* The second axis */
  num_ortho_axis = get_orthogonal_axis( ortho_axes, prop_rot, 2 );
  if ( ! num_ortho_axis ) { goto err; }
  
  min_norm = 8;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    norm = mat_norm_squared_i3( rot_axes[ortho_axes[i]] );
    if ( norm < min_norm ) {
      min_norm = norm;
      axes[0] = ortho_axes[i];
      is_found = 1;
    }
  }
  if ( ! is_found ) { goto err; }
  
  /* The third axis */
  min_norm = 8;
  is_found = 0;
  for ( i = 0; i < num_ortho_axis; i++ ) {
    norm = mat_norm_squared_i3( rot_axes[ortho_axes[i]] );
    if ( norm < min_norm && ( ! ( ortho_axes[i] == axes[0] ) ) ) {
      min_norm = norm;
      axes[2] = ortho_axes[i];
      is_found = 1;
    }
  }
  if ( ! is_found ) { goto err; }

  get_transform_matrix( t_mat, axes );
  if ( mat_get_determinant_i3( t_mat ) < 0 ) {
    tmpval = axes[0];
    axes[0] = axes[2];
    axes[2] = tmpval;
  }

  return 1;

 err:
  return 0;
}