+status_t MesaDriver::CopyPixelsOut(BPoint location, BBitmap *bitmap)
+{
+ color_space scs = m_bitmap->ColorSpace();
+ color_space dcs = bitmap->ColorSpace();
+
+ if (scs != dcs && (scs != B_RGBA32 || dcs != B_RGB32)) {
+ printf("CopyPixelsOut(): incompatible color space: %s != %s\n",
+ color_space_name(scs),
+ color_space_name(dcs));
+ return B_BAD_TYPE;
+ }
+
+ // debugger("CopyPixelsOut()");
+
+ BRect sr = m_bitmap->Bounds();
+ BRect dr = bitmap->Bounds();
+
+ sr = sr & dr.OffsetBySelf(location);
+ dr = sr.OffsetByCopy(-location.x, -location.y);
+
+ uint8 *ps = (uint8 *) m_bitmap->Bits();
+ uint8 *pd = (uint8 *) bitmap->Bits();
+ uint32 *s, *d;
+ uint32 y;
+ for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
+ s = (uint32 *) (ps + y * m_bitmap->BytesPerRow());
+ s += (uint32) sr.left;
+
+ d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * bitmap->BytesPerRow());
+ d += (uint32) dr.left;
+
+ memcpy(d, s, dr.IntegerWidth() * 4);
+ }
+ return B_OK;
+}
+
+status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location)
+{
+ color_space scs = bitmap->ColorSpace();
+ color_space dcs = m_bitmap->ColorSpace();
+
+ if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
+ printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
+ color_space_name(scs),
+ color_space_name(dcs));
+ return B_BAD_TYPE;
+ }
+
+ // debugger("CopyPixelsIn()");
+
+ BRect sr = bitmap->Bounds();
+ BRect dr = m_bitmap->Bounds();
+
+ sr = sr & dr.OffsetBySelf(location);
+ dr = sr.OffsetByCopy(-location.x, -location.y);
+
+ uint8 *ps = (uint8 *) bitmap->Bits();
+ uint8 *pd = (uint8 *) m_bitmap->Bits();
+ uint32 *s, *d;
+ uint32 y;
+ for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
+ s = (uint32 *) (ps + y * bitmap->BytesPerRow());
+ s += (uint32) sr.left;
+
+ d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * m_bitmap->BytesPerRow());
+ d += (uint32) dr.left;
+
+ memcpy(d, s, dr.IntegerWidth() * 4);
+ }
+ return B_OK;
+}
+