I am trying to understand the calculations in the following solved exercise:
Let $X$ and $Y$ two independent random variables with pdf $f(x)=2x, x\in (0,1); f(x)=0, \text{otherwise}$. Determine the pdf of $Z=X+Y$.
For $z\in (0,1)$: $$f_Z(z)=\int_{\mathbb{R}}2x 1_{(0,1)}(x) 2(z-x)1_{(z-1,z)}(x)dx=\int_{0}^{z}2x2(z-x)=\frac{2}{3}z^3.$$
For $z\in (1,2)$: $$f_Z(z)=\int_{\mathbb{R}}2x 1_{(0,1)}(x) 2(z-x)1_{(z-1,z)}(x)dx=\int_{z-1}^{1} 2x2(z-x)dx=\frac{2}{3}(6z-z^3-4).$$
I know the definition of convolution and I get why we are using it to compute the pdf of the sum of two random variables but I don't get why are the endpoints of the integral in the first case $0$ and $z$ and why are they in the second case $z-1$ and $1$?