#include "main/enums.h"
#include "main/image.h"
#include "main/colormac.h"
+#include "main/condrender.h"
#include "main/mtypes.h"
#include "main/macros.h"
+#include "main/pbo.h"
#include "main/bufferobj.h"
#include "main/state.h"
#include "main/texobj.h"
#include "main/context.h"
+#include "main/fbobject.h"
#include "swrast/swrast.h"
#include "drivers/common/meta.h"
if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
GL_COLOR_INDEX, GL_BITMAP,
- (GLvoid *) bitmap)) {
+ INT_MAX, (const GLvoid *) bitmap)) {
_mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
return NULL;
}
- buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- GL_READ_ONLY_ARB,
- unpack->BufferObj);
+ buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ unpack->BufferObj);
if (!buf) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
return NULL;
return ADD_POINTERS(buf, bitmap);
}
-static GLboolean test_bit( const GLubyte *src, GLuint bit )
+static bool test_bit( const GLubyte *src, GLuint bit )
{
return (src[bit/8] & (1<<(bit % 8))) ? 1 : 0;
}
GLuint w, GLuint h,
GLubyte *dest,
GLuint row_align,
- GLboolean invert)
+ bool invert)
{
GLuint src_offset = (x + unpack->SkipPixels) & 0x7;
GLuint mask = unpack->LsbFirst ? 0 : 7;
GLint incr;
GLuint count = 0;
- if (INTEL_DEBUG & DEBUG_PIXEL)
- printf("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
- __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
+ DBG("%s %d,%d %dx%d bitmap %dx%d skip %d src_offset %d mask %d\n",
+ __FUNCTION__, x,y,w,h,width,height,unpack->SkipPixels, src_offset, mask);
if (invert) {
first = h-1;
static INLINE int
y_flip(struct gl_framebuffer *fb, int y, int height)
{
- if (fb->Name != 0)
+ if (_mesa_is_user_fbo(fb))
return y;
else
return fb->Height - y - height;
/*
* Render a bitmap.
*/
-static GLboolean
+static bool
do_blit_bitmap( struct gl_context *ctx,
GLint dstx, GLint dsty,
GLsizei width, GLsizei height,
const GLubyte *bitmap )
{
struct intel_context *intel = intel_context(ctx);
- struct intel_region *dst = intel_drawbuf_region(intel);
+ struct intel_region *dst;
struct gl_framebuffer *fb = ctx->DrawBuffer;
GLfloat tmpColor[4];
GLubyte ubcolor[4];
* It seems the blit Z coord is always 1.0 (the far plane) so fragments
* will likely be obscured by other, closer geometry.
*/
- return GL_FALSE;
+ return false;
}
+ intel_prepare_render(intel);
+ dst = intel_drawbuf_region(intel);
+
if (!dst)
- return GL_FALSE;
+ return false;
if (_mesa_is_bufferobj(unpack->BufferObj)) {
bitmap = map_pbo(ctx, width, height, unpack, bitmap);
if (bitmap == NULL)
- return GL_TRUE; /* even though this is an error, we're done */
+ return true; /* even though this is an error, we're done */
}
COPY_4V(tmpColor, ctx->Current.RasterColor);
- if (NEED_SECONDARY_COLOR(ctx)) {
+ if (_mesa_need_secondary_color(ctx)) {
ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor);
}
color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
- return GL_FALSE;
-
- intel_prepare_render(intel);
+ return false;
/* Clip to buffer bounds and scissor. */
if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
* Have to translate destination coordinates back into source
* coordinates.
*/
- if (get_bitmap_rect(bitmap_width, bitmap_height, unpack,
- bitmap,
- -orig_dstx + (dstx + px),
- -orig_dsty + y_flip(fb, dsty + py, h),
- w, h,
- (GLubyte *)stipple,
- 8,
- fb->Name == 0 ? GL_TRUE : GL_FALSE) == 0)
+ int count = get_bitmap_rect(bitmap_width, bitmap_height, unpack,
+ bitmap,
+ -orig_dstx + (dstx + px),
+ -orig_dsty + y_flip(fb, dsty + py, h),
+ w, h,
+ (GLubyte *)stipple,
+ 8,
+ _mesa_is_winsys_fbo(fb));
+ if (count == 0)
continue;
if (!intelEmitImmediateColorExpandBlit(intel,
sz,
color,
dst->pitch,
- dst->buffer,
+ dst->bo,
0,
dst->tiling,
dstx + px,
dsty + py,
w, h,
logic_op)) {
- return GL_FALSE;
+ return false;
}
+
+ if (ctx->Query.CurrentOcclusionObject)
+ ctx->Query.CurrentOcclusionObject->Result += count;
}
}
out:
- if (INTEL_DEBUG & DEBUG_SYNC)
- intel_batchbuffer_flush(intel->batch);
+ if (unlikely(INTEL_DEBUG & DEBUG_SYNC))
+ intel_batchbuffer_flush(intel);
if (_mesa_is_bufferobj(unpack->BufferObj)) {
/* done with PBO so unmap it now */
- ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
- unpack->BufferObj);
+ ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj);
}
intel_check_front_buffer_rendering(intel);
- return GL_TRUE;
+ return true;
}
+
/* There are a large number of possible ways to implement bitmap on
* this hardware, most of them have some sort of drawback. Here are a
* few that spring to mind:
const struct gl_pixelstore_attrib *unpack,
const GLubyte * pixels)
{
- struct intel_context *intel = intel_context(ctx);
+ if (!_mesa_check_conditional_render(ctx))
+ return;
if (do_blit_bitmap(ctx, x, y, width, height,
unpack, pixels))
return;
- /* FIXME */
- if (intel->gen == 6)
- return _swrast_Bitmap(ctx, x, y, width, height, unpack, pixels);
-
_mesa_meta_Bitmap(ctx, x, y, width, height, unpack, pixels);
}