void XYView::move_view(Coord dx1, Coord dy1) { // printf("move by %g %g \n", dx1, dy1); Coord x0, x1, y0, y1; Coord dx = Math::abs(dx1); Coord dy = Math::abs(dy1); if (dx < .9*dy) { dx = 0.; dy = dy1; } else if (dy < .9*dx) { dx = dx1; dy = 0.; } else { dx = dx1; dy = dy1; } s2o().transform(0, 0, x0, y0); s2o().transform(dx, dy, x1, y1); x0 = x0 - x1 + left(); y0 = y0 - y1 + bottom(); x1 = x0 + width(); y1 = y0 + height(); #if 1 if (dx > 0) { MyMath::round(x0, x1, MyMath::Higher, 4); } else { MyMath::round(x0, x1, MyMath::Lower, 4); } if (dy > 0) { MyMath::round(y0, y1, MyMath::Higher, 4); } else { MyMath::round(y0, y1, MyMath::Lower, 4); } #endif XYView::origin(x0, y0); damage_all(); }
cluster_t exfat_next_cluster(const struct exfat* ef, const struct exfat_node* node, cluster_t cluster) { le32_t next; off_t fat_offset; if (cluster < EXFAT_FIRST_DATA_CLUSTER) exfat_bug("bad cluster 0x%x", cluster); if (IS_CONTIGUOUS(*node)) return cluster + 1; fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start)) + cluster * sizeof(cluster_t); exfat_pread(ef->dev, &next, sizeof(next), fat_offset); return le32_to_cpu(next); }
cluster_t exfat_next_cluster(const struct exfat* ef, const struct exfat_node* node, cluster_t cluster) { le32_t next; loff_t fat_offset; if (cluster < EXFAT_FIRST_DATA_CLUSTER) exfat_bug("bad cluster 0x%x", cluster); if (IS_CONTIGUOUS(*node)) return cluster + 1; fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start)) + cluster * sizeof(cluster_t); /* FIXME handle I/O error */ if (exfat_pread(ef->dev, &next, sizeof(next), fat_offset) < 0) exfat_bug("failed to read the next cluster after %#x", cluster); return le32_to_cpu(next); }
static bool set_next_cluster(const struct exfat* ef, bool contiguous, cluster_t current, cluster_t next) { loff_t fat_offset; le32_t next_le32; if (contiguous) return true; fat_offset = s2o(ef, le32_to_cpu(ef->sb->fat_sector_start)) + current * sizeof(cluster_t); next_le32 = cpu_to_le32(next); if (exfat_pwrite(ef->dev, &next_le32, sizeof(next_le32), fat_offset) < 0) { exfat_error("failed to write the next cluster %#x after %#x", next, current); return false; } return true; }
/* * Cluster to absolute offset. */ off_t exfat_c2o(const struct exfat* ef, cluster_t cluster) { return s2o(ef, c2s(ef, cluster)); }
XYView* View::new_view(Coord x1, Coord y1, Coord x2, Coord y2) { Coord l,b,r,t; s2o().inverse_transform(x1,y1,l,b); s2o().inverse_transform(x2,y2,r,t); return new View( (x1+x2)/2, (y1+y2)/2, x2-x1, scene(), r-l, t-b); }
XYView* XYView::new_view(Coord x1, Coord y1, Coord x2, Coord y2) { Coord l,b,r,t; s2o().inverse_transform(x1,y1,l,b); s2o().inverse_transform(x2,y2,r,t); return new XYView( x1, y1, x2-x1, y2-y1, scene(), r-l, t-b); }