fb: correct invert_area image calculation

Fix the wrong calculation for inverting implemented by
commit 70685875059f
("fb: cfb: support inverting with coordinates that do not align
with the tile")

Fixed not enough consideration when the drawing area height
is eight lines or less.
Simplify to XOR calculation.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
diff --git a/subsys/fb/cfb.c b/subsys/fb/cfb.c
index 4730d63..52b4068 100644
--- a/subsys/fb/cfb.c
+++ b/subsys/fb/cfb.c
@@ -355,27 +355,34 @@
 					uint8_t m = BIT_MASK((j % 8));
 					uint8_t b = fb->buf[index];
 
-					if (need_reverse) {
-						m = byte_reverse(m);
-						b = byte_reverse(b);
+					/*
+					 * Generate mask for remaining lines in case of
+					 * drawing within 8 lines from the start line
+					 */
+					if (remains < 8) {
+						m |= BIT_MASK((8 - (j % 8) + remains))
+						     << ((j % 8) + remains);
 					}
 
-					fb->buf[index] = ~(b | m) | (b & m);
+					if (need_reverse) {
+						m = byte_reverse(m);
+					}
+
+					fb->buf[index] = (b ^ (~m));
 					j += 7 - (j % 8);
 				} else if (remains >= 8) {
 					/* No mask required if no start or end line is included */
 					fb->buf[index] = ~fb->buf[index];
 					j += 7;
 				} else {
-					uint8_t m = BIT_MASK(remains % 8) << (8 - (remains % 8));
+					uint8_t m = BIT_MASK(8 - remains) << (remains);
 					uint8_t b = fb->buf[index];
 
 					if (need_reverse) {
 						m = byte_reverse(m);
-						b = byte_reverse(b);
 					}
 
-					fb->buf[index] = ~(b | m) | (b & m);
+					fb->buf[index] = (b ^ (~m));
 					j += (remains - 1);
 				}
 			}