Select Git revision
raster.cpp 6.56 KiB
/* libs/pixelflinger/raster.cpp
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include <string.h>
#include "raster.h"
#include "trap.h"
namespace android {
static void ggl_rasterPos2x(void* con, GGLfixed x, GGLfixed y);
static void ggl_rasterPos2i(void* con, GGLint x, GGLint y);
static void ggl_copyPixels(void* con, GGLint xs, GGLint ys,
GGLsizei width, GGLsizei height, GGLenum type);
void ggl_init_raster(context_t* c)
{
GGLContext& procs = *(GGLContext*)c;
GGL_INIT_PROC(procs, copyPixels);
GGL_INIT_PROC(procs, rasterPos2x);
GGL_INIT_PROC(procs, rasterPos2i);
}
void ggl_rasterPos2x(void* con, GGLfixed x, GGLfixed y)
{
GGL_CONTEXT(c, con);
// raster pos should be processed just like glVertex
c->state.raster.x = x;
c->state.raster.y = y;
}
void ggl_rasterPos2i(void* con, GGLint x, GGLint y)
{
ggl_rasterPos2x(con, gglIntToFixed(x), gglIntToFixed(y));
}
void ggl_copyPixels(void* con, GGLint xs, GGLint ys,
GGLsizei width, GGLsizei height, GGLenum type)
{
GGL_CONTEXT(c, con);
// color-buffer
surface_t* cb = &(c->state.buffers.color);
// undefined behaviour if we try to copy from outside the surface
if (uint32_t(xs) > cb->width)
return;
if (uint32_t(ys) > cb->height)
return;
if (uint32_t(xs + width) > cb->width)
return;
if (uint32_t(ys + height) > cb->height)
return;