示例#1
0
/**
*
* Sets logiWIN desired rectangle.
*
* @param    lw is a pointer to the logiWIN device parameter structure.
* @param    x is a upper left coordinate of the cropping/output rectangle.
* @param    y is a upper right coordinate of the cropping/output rectangle.
* @param    w is a width of the cropping/output rectangle.
* @param    h is a height of the cropping/output rectangle.
* @param    rect_type a flag for choosing between cropping and output rectangle.
*
* @return   None.
*
* @note     None.
*
*****************************************************************************/
void logiwin_set_rect_parameters(struct logiwin_priv *lw,
    unsigned long x, unsigned long y,
    unsigned long w, unsigned long h,
    enum logiwin_rectangle rect_type)
{
    struct logiwin_rect out_rect;

    if ((x % lw->out_byte_align))
        x = x & lw->out_byte_align_mask;
    if ((w % lw->out_byte_align))
        w = w & lw->out_byte_align_mask;

    switch (rect_type) {
    case CROPPING_RECTANGLE:
        lw->in_crop_rect.x = x;
        lw->in_crop_rect.y = y;
        lw->in_crop_rect.width = w;
        lw->in_crop_rect.height = h;

        crop_rect(&lw->in_crop_rect, &lw->in_bounds_rect);

        break;

    case OUTPUT_RECTANGLE:
        lw->out_rect.x = x & lw->out_byte_align_mask;
        lw->out_rect.y = y;
        lw->out_rect.width = w & lw->out_byte_align_mask;
        lw->out_rect.height = h;

        out_rect.x = 0;
        out_rect.y = 0;
        out_rect.width = lw->max_out_hres;
        out_rect.height = lw->max_out_vres;
        crop_rect(&lw->out_rect, &out_rect);

        if (lw->weave_deinterlace) {
            lw->out_rect.y /= 2;
            lw->out_rect.height /= 2;
        }
        break;

    case INBOUNDS_RECTANGLE:
        lw->in_bounds_rect.x = x;
        lw->in_bounds_rect.y = y;
        lw->in_bounds_rect.width = w;
        lw->in_bounds_rect.height = h;

        crop_rect(&lw->in_crop_rect, &lw->in_bounds_rect);

        break;
    }
}
示例#2
0
static void ConstructCommands(const hwc_layer_1 *layers, size_t num_layers,
                              std::vector<RenderingCommand> *commands) {
  std::vector<FRect> in_rects;
  std::vector<FRectSet> out_rects;
  int i;

  for (unsigned rect_index = 0; rect_index < num_layers; rect_index++) {
    const hwc_layer_1 &layer = layers[rect_index];
    FRect rect;
    in_rects.push_back(FRect(layer.displayFrame.left, layer.displayFrame.top,
                             layer.displayFrame.right,
                             layer.displayFrame.bottom));
  }

  seperate_frects_64(in_rects, &out_rects);

  for (unsigned rect_index = 0; rect_index < out_rects.size(); rect_index++) {
    const FRectSet &out_rect = out_rects[rect_index];
    commands->push_back(RenderingCommand());
    RenderingCommand &cmd = commands->back();

    memcpy(cmd.bounds, out_rect.rect.bounds, sizeof(cmd.bounds));

    uint64_t tex_set = out_rect.id_set.getBits();
    for (unsigned i = num_layers - 1; tex_set != 0x0; i--) {
      if (tex_set & (0x1 << i)) {
        tex_set &= ~(0x1 << i);

        const hwc_layer_1 &layer = layers[i];

        FRect display_rect(layer.displayFrame.left, layer.displayFrame.top,
                           layer.displayFrame.right, layer.displayFrame.bottom);
        float display_size[2] = {
            display_rect.bounds[2] - display_rect.bounds[0],
            display_rect.bounds[3] - display_rect.bounds[1]};

        FRect crop_rect(layer.sourceCropf.left, layer.sourceCropf.top,
                        layer.sourceCropf.right, layer.sourceCropf.bottom);
        float crop_size[2] = {crop_rect.bounds[2] - crop_rect.bounds[0],
                              crop_rect.bounds[3] - crop_rect.bounds[1]};

        RenderingCommand::TextureSource &src = cmd.textures[cmd.texture_count];
        cmd.texture_count++;
        src.texture_index = i;

        for (int b = 0; b < 4; b++) {
          float bound_percent = (cmd.bounds[b] - display_rect.bounds[b % 2]) /
                                display_size[b % 2];
          src.crop_bounds[b] =
              crop_rect.bounds[b % 2] + bound_percent * crop_size[b % 2];
        }

        if (layer.blending == HWC_BLENDING_NONE) {
          src.alpha = 1.0f;
          // This layer is opaque. There is no point in using layers below this
          // one.
          break;
        }

        src.alpha = layer.planeAlpha / 255.0f;
      }
    }
  }
}
    virtual void onDraw(SkCanvas* canvas) {
        SkAutoTUnref<SkColorFilter> cf(
            SkColorFilter::CreateModeFilter(SK_ColorBLUE, SkXfermode::kSrcIn_Mode));
        SkImageFilter::CropRect crop_rect(
            SkRect::Make(SkIRect::MakeXYWH(10, 10, 44, 44)),
            SkImageFilter::CropRect::kHasAll_CropEdge);

        SkBitmap gradient_circle, checkerboard;
        make_gradient_circle(64, 64, &gradient_circle);
        make_checkerboard(&checkerboard);

        SkAutoTUnref<SkImageFilter> gradient_circle_source(
            SkBitmapSource::Create(gradient_circle));
        SkAutoTUnref<SkImageFilter> noop_cropped(
            SkOffsetImageFilter::Create(0, 0, NULL, &crop_rect));
        SkScalar sk255 = SkIntToScalar(255);
        SkScalar matrix[20] = { 1, 0, 0, 0, 0,
                                0, 1, 0, 0, sk255,
                                0, 0, 1, 0, 0,
                                0, 0, 0, 0, sk255 };
        SkAutoTUnref<SkColorFilter> cf_alpha_trans(SkColorMatrixFilter::Create(matrix));

        SkRect r = SkRect::MakeWH(SkIntToScalar(64), SkIntToScalar(64));
        SkScalar MARGIN = SkIntToScalar(12);

        SkIRect bounds;
        r.roundOut(&bounds);

        SkPaint paint;
        canvas->translate(MARGIN, MARGIN);
        for (int outset = -15; outset <= 20; outset += 5) {
            canvas->save();
            SkRect rect = crop_rect.rect();
            rect.outset(SkIntToScalar(outset),
                        SkIntToScalar(outset));
            SkImageFilter::CropRect big_rect(rect, SkImageFilter::CropRect::kHasAll_CropEdge);

            draw(canvas, checkerboard, rect, SkColorFilterImageFilter::Create(
                cf_alpha_trans, noop_cropped.get(), &big_rect));

            draw(canvas, checkerboard, rect, SkBlurImageFilter::Create(
                8.0f, 8.0f, noop_cropped.get(), &big_rect));

            draw(canvas, checkerboard, rect, SkDilateImageFilter::Create(
                2, 2, noop_cropped.get(), &big_rect));

            draw(canvas, checkerboard, rect, SkErodeImageFilter::Create(
                2, 2, noop_cropped.get(), &big_rect));

            draw(canvas, checkerboard, rect, SkDropShadowImageFilter::Create(
                SkIntToScalar(10), SkIntToScalar(10), SkIntToScalar(3), SkIntToScalar(3),
                SK_ColorBLUE, noop_cropped.get(), &big_rect));

            draw(canvas, checkerboard, rect, SkDisplacementMapEffect::Create(
                SkDisplacementMapEffect::kR_ChannelSelectorType,
                SkDisplacementMapEffect::kR_ChannelSelectorType,
                SkIntToScalar(12),
                gradient_circle_source.get(),
                noop_cropped.get(),
                &big_rect));

            draw(canvas, checkerboard, rect, SkOffsetImageFilter::Create(
                SkIntToScalar(-8), SkIntToScalar(16), noop_cropped.get(), &big_rect));

            canvas->restore();
            canvas->translate(0, SkIntToScalar(80));
        }
    }