/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"BufferEdgePad.h"
#include"2D.h"// for DrawTarget #include"Point.h"// for IntSize #include"Types.h"// for SurfaceFormat
#include"nsRegion.h"
namespace mozilla { namespace gfx {
void PadDrawTargetOutFromRegion(DrawTarget* aDrawTarget, const nsIntRegion& aRegion) { struct LockedBits {
uint8_t* data;
IntSize size;
int32_t stride;
SurfaceFormat format; staticint clamp(int x, int min, int max) { if (x < min) x = min; if (x > max) x = max; return x;
}
staticvoid ensure_memcpy(uint8_t* dst, uint8_t* src, size_t n,
uint8_t* bitmap, int stride, int height) { if (src + n > bitmap + stride * height) {
MOZ_CRASH("GFX: long src memcpy");
} if (src < bitmap) {
MOZ_CRASH("GFX: short src memcpy");
} if (dst + n > bitmap + stride * height) {
MOZ_CRASH("GFX: long dst mempcy");
} if (dst < bitmap) {
MOZ_CRASH("GFX: short dst mempcy");
}
}
staticvoid visitor(void* closure, VisitSide side, int x1, int y1, int x2, int y2) {
LockedBits* lb = static_cast<LockedBits*>(closure);
uint8_t* bitmap = lb->data; constint bpp = gfx::BytesPerPixel(lb->format); constint stride = lb->stride; constint width = lb->size.width; constint height = lb->size.height;
if (aDrawTarget->LockBits(&lb.data, &lb.size, &lb.stride, &lb.format)) { // we can only pad software targets so if we can't lock the bits don't pad
aRegion.VisitEdges(lb.visitor, &lb);
aDrawTarget->ReleaseBits(lb.data);
}
}
} // namespace gfx
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.