Compare commits
2 Commits
GTK2_BRANC
...
regalloc_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c43d4984f | ||
|
|
cfe021ff88 |
134
mozilla/ef/Compiler/RegisterAllocator/BitSet.cpp
Normal file
134
mozilla/ef/Compiler/RegisterAllocator/BitSet.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
// Return the next bit after index set to true or -1 if none.
|
||||
//
|
||||
Int32 BitSet::nextOne(Int32 pos) const
|
||||
{
|
||||
++pos;
|
||||
|
||||
if (pos < 0 || Uint32(pos) >= universeSize)
|
||||
return -1;
|
||||
|
||||
Uint32 offset = getWordOffset(pos);
|
||||
Uint8 index = getBitOffset(pos);
|
||||
Word* ptr = &word[offset];
|
||||
Word currentWord = *ptr++ >> index;
|
||||
|
||||
if (currentWord != Word(0)) {
|
||||
while ((currentWord & Word(1)) == 0) {
|
||||
++index;
|
||||
currentWord >>= 1;
|
||||
}
|
||||
return (offset << nBitsInWordLog2) + index;
|
||||
}
|
||||
|
||||
Word* limit = &word[getSizeInWords(universeSize)];
|
||||
while (ptr < limit) {
|
||||
++offset;
|
||||
currentWord = *ptr++;
|
||||
if (currentWord != Word(0)) {
|
||||
index = 0;
|
||||
while ((currentWord & Word(1)) == 0) {
|
||||
++index;
|
||||
currentWord >>= 1;
|
||||
}
|
||||
return (offset << nBitsInWordLog2) + index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return the next bit after index set to false or -1 if none.
|
||||
//
|
||||
Int32 BitSet::nextZero(Int32 pos) const
|
||||
{
|
||||
++pos;
|
||||
|
||||
if (pos < 0 || Uint32(pos) >= universeSize)
|
||||
return -1;
|
||||
|
||||
Uint32 offset = getWordOffset(pos);
|
||||
Uint8 index = getBitOffset(pos);
|
||||
Word* ptr = &word[offset];
|
||||
Word currentWord = *ptr++ >> index;
|
||||
|
||||
if (currentWord != Word(~0)) {
|
||||
for (; index < nBitsInWord; ++index) {
|
||||
if ((currentWord & Word(1)) == 0) {
|
||||
Int32 ret = (offset << nBitsInWordLog2) + index;
|
||||
return (Uint32(ret) < universeSize) ? ret : -1;
|
||||
}
|
||||
currentWord >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
Word* limit = &word[getSizeInWords(universeSize)];
|
||||
while (ptr < limit) {
|
||||
++offset;
|
||||
currentWord = *ptr++;
|
||||
if (currentWord != Word(~0)) {
|
||||
for (index = 0; index < nBitsInWord; ++index) {
|
||||
if ((currentWord & Word(1)) == 0) {
|
||||
Int32 ret = (offset << nBitsInWordLog2) + index;
|
||||
return (Uint32(ret) < universeSize) ? ret : -1;
|
||||
}
|
||||
currentWord >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
|
||||
// Print the set.
|
||||
//
|
||||
void BitSet::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("[ "));
|
||||
|
||||
for (Int32 i = firstOne(); i != -1; i = nextOne(i)) {
|
||||
Int32 currentBit = i;
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", currentBit));
|
||||
|
||||
Int32 nextBit = nextOne(currentBit);
|
||||
if (nextBit != currentBit + 1) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" "));
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((nextBit != -1) && (nextBit == (currentBit + 1))) {
|
||||
currentBit = nextBit;
|
||||
nextBit = nextOne(nextBit);
|
||||
}
|
||||
|
||||
if (currentBit > (i+1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("-%d ", currentBit));
|
||||
else
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" %d ", currentBit));
|
||||
|
||||
i = currentBit;
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("]\n"));
|
||||
}
|
||||
|
||||
#endif // DEBUG_LOG
|
||||
195
mozilla/ef/Compiler/RegisterAllocator/BitSet.h
Normal file
195
mozilla/ef/Compiler/RegisterAllocator/BitSet.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _BITSET_H_
|
||||
#define _BITSET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "Pool.h"
|
||||
#include <string.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BitSet -
|
||||
|
||||
class BitSet
|
||||
{
|
||||
private:
|
||||
|
||||
#if (PR_BITS_PER_WORD == 64)
|
||||
typedef Uint64 Word;
|
||||
#elif (PR_BITS_PER_WORD == 32)
|
||||
typedef Uint32 Word;
|
||||
#endif
|
||||
|
||||
static const nBitsInWord = PR_BITS_PER_WORD;
|
||||
static const nBytesInWord = PR_BYTES_PER_WORD;
|
||||
static const nBitsInWordLog2 = PR_BITS_PER_WORD_LOG2;
|
||||
static const nBytesInWordLog2 = PR_BYTES_PER_WORD_LOG2;
|
||||
|
||||
// Return the number of Word need to store the universe.
|
||||
static Uint32 getSizeInWords(Uint32 sizeOfUniverse) {return (sizeOfUniverse + (nBitsInWord - 1)) >> nBitsInWordLog2;}
|
||||
// Return the given element offset in its containing Word.
|
||||
static Uint32 getBitOffset(Uint32 element) {return element & (nBitsInWord - 1);}
|
||||
// Return the Word offset for the given element int the universe.
|
||||
static Uint32 getWordOffset(Uint32 element) {return element >> nBitsInWordLog2;}
|
||||
// Return the mask for the given bit index.
|
||||
static Word getMask(Uint8 index) {return Word(1) << index;}
|
||||
|
||||
private:
|
||||
|
||||
Uint32 universeSize; // Size of the universe
|
||||
Word* word; // universe memory.
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
BitSet(const BitSet&);
|
||||
|
||||
// Check if the given set's universe is of the same size than this universe.
|
||||
void checkUniverseCompatibility(const BitSet& set) const {assert(set.universeSize == universeSize);}
|
||||
// Check if pos is valid for this set's universe.
|
||||
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
|
||||
|
||||
public:
|
||||
|
||||
// Create a bitset of universeSize bits.
|
||||
BitSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {word = new(pool) Word[getSizeInWords(universeSize)]; clear();}
|
||||
|
||||
// Return the size of this bitset.
|
||||
Uint32 getSize() const {return universeSize;}
|
||||
|
||||
// Clear the bitset.
|
||||
void clear() {memset(word, 0x00, getSizeInWords(universeSize) << nBytesInWordLog2);}
|
||||
// Clear the bit at index.
|
||||
void clear(Uint32 index) {checkMember(index); word[getWordOffset(index)] &= ~getMask(index);}
|
||||
// Set the bitset.
|
||||
void set() {memset(word, 0xFF, getSizeInWords(universeSize) << nBytesInWordLog2);}
|
||||
// Set the bit at index.
|
||||
void set(Uint32 index) {checkMember(index); word[getWordOffset(index)] |= getMask(index);}
|
||||
// Return true if the bit at index is set.
|
||||
bool test(Uint32 index) const {checkMember(index); return (word[getWordOffset(index)] & getMask(index)) != 0;}
|
||||
// Union with the given bitset.
|
||||
inline void or(const BitSet& set);
|
||||
// Intersection with the given bitset.
|
||||
inline void and(const BitSet& set);
|
||||
// Difference with the given bitset.
|
||||
inline void difference(const BitSet& set);
|
||||
// Copy set.
|
||||
inline BitSet& operator = (const BitSet& set);
|
||||
// Return true if the bitset are identical.
|
||||
friend bool operator == (const BitSet& set1, const BitSet& set2);
|
||||
// Return true if the bitset are different.
|
||||
friend bool operator != (const BitSet& set1, const BitSet& set2);
|
||||
|
||||
// Logical operators.
|
||||
BitSet& operator |= (const BitSet& set) {or(set); return *this;}
|
||||
BitSet& operator &= (const BitSet& set) {and(set); return *this;}
|
||||
BitSet& operator -= (const BitSet& set) {difference(set); return *this;}
|
||||
|
||||
// Return the first bit at set to true or -1 if none.
|
||||
Int32 firstOne() const {return nextOne(-1);}
|
||||
// Return the next bit after index set to true or -1 if none.
|
||||
Int32 nextOne(Int32 pos) const;
|
||||
// Return the first bit at set to false or -1 if none.
|
||||
Int32 firstZero() const {return nextZero(-1);}
|
||||
// Return the next bit after index set to false or -1 if none.
|
||||
Int32 nextZero(Int32 pos) const;
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef Int32 iterator;
|
||||
// Return true if the walk is ordered.
|
||||
static bool isOrdered() {return true;}
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const {return firstOne();}
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const {return nextOne(pos);}
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos == -1;}
|
||||
// Return the element corresponding to the given iterator.
|
||||
Uint32 get(iterator pos) const {return pos;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
// Union with the given bitset.
|
||||
//
|
||||
inline void BitSet::or(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ |= *src++;
|
||||
}
|
||||
|
||||
// Intersection with the given bitset.
|
||||
//
|
||||
inline void BitSet::and(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ &= *src++;
|
||||
}
|
||||
|
||||
// Difference with the given bitset.
|
||||
//
|
||||
inline void BitSet::difference(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ &= ~*src++;
|
||||
}
|
||||
|
||||
// Copy the given set into this set.
|
||||
//
|
||||
inline BitSet& BitSet::operator = (const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
if (this != &set)
|
||||
memcpy(word, set.word, getSizeInWords(universeSize) << nBytesInWordLog2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Return true if the given set is identical to this set.
|
||||
inline bool operator == (const BitSet& set1, const BitSet& set2)
|
||||
{
|
||||
set1.checkUniverseCompatibility(set2);
|
||||
|
||||
if (&set1 == &set2)
|
||||
return true;
|
||||
|
||||
return memcmp(set1.word, set2.word, BitSet::getSizeInWords(set1.universeSize) << BitSet::nBytesInWordLog2) == 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const BitSet& set1, const BitSet& set2) {return !(set1 == set2);}
|
||||
|
||||
#endif // _BITSET_H
|
||||
159
mozilla/ef/Compiler/RegisterAllocator/Coalescing.h
Normal file
159
mozilla/ef/Compiler/RegisterAllocator/Coalescing.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _COALESCING_H_
|
||||
#define _COALESCING_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "SparseSet.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
#if 1
|
||||
// Performing an ultra conservative coalescing meens that when we look at
|
||||
// candidates (source,destination) for coalescing we need to make sure
|
||||
// that the combined interference of the source and destination register
|
||||
// will not exceed the total number of register available for the register
|
||||
// class.
|
||||
#define ULTRA_CONSERVATIVE_COALESCING
|
||||
#else
|
||||
// If we are not doing an ultra conservative coalescing we have to make sure
|
||||
// that the total number of neighbor whose degree is greater than the total
|
||||
// number of register is not greater than the total number of register.
|
||||
#undef ULTRA_CONSERVATIVE_COALESCING
|
||||
#endif
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Coalescing
|
||||
{
|
||||
static bool coalesce(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coalescing<RegisterPressure>::coalesce(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
|
||||
// Initialize the lookup table
|
||||
//
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* newRange = new RegisterName[2 * rangeCount];
|
||||
RegisterName* coalescedRange = &newRange[rangeCount];
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
init(coalescedRange, rangeCount);
|
||||
|
||||
SparseSet interferences(pool, rangeCount);
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
bool removedInstructions = false;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.lndList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
|
||||
// Walk the nodes in the loop nesting depth list.
|
||||
for (Int32 n = nNodes - 1; n >= 0; n--) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
InstructionList::iterator it = instructions.begin();
|
||||
while (!instructions.done(it)) {
|
||||
Instruction& instruction = instructions.get(it);
|
||||
it = instructions.advance(it);
|
||||
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
|
||||
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
|
||||
|
||||
RegisterName source = findRoot(name2range[instruction.getInstructionUseBegin()[0].getRegisterName()], coalescedRange);
|
||||
RegisterName destination = findRoot(name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()], coalescedRange);
|
||||
|
||||
if (source == destination) {
|
||||
instruction.remove();
|
||||
} else if (!iGraph.interfere(source, destination)) {
|
||||
InterferenceVector* sourceVector = iGraph.getInterferenceVector(source);
|
||||
InterferenceVector* destinationVector = iGraph.getInterferenceVector(destination);
|
||||
|
||||
#ifdef ULTRA_CONSERVATIVE_COALESCING
|
||||
interferences.clear();
|
||||
|
||||
InterferenceVector* vector;
|
||||
for (vector = sourceVector; vector != NULL; vector = vector->next) {
|
||||
RegisterName* neighbors = vector->neighbors;
|
||||
for (Uint32 i = 0; i < vector->count; i++)
|
||||
interferences.set(findRoot(neighbors[i], coalescedRange));
|
||||
}
|
||||
for (vector = destinationVector; vector != NULL; vector = vector->next) {
|
||||
RegisterName* neighbors = vector->neighbors;
|
||||
for (Uint32 i = 0; i < vector->count; i++)
|
||||
interferences.set(findRoot(neighbors[i], coalescedRange));
|
||||
}
|
||||
|
||||
Uint32 count = interferences.getSize();
|
||||
#else // ULTRA_CONSERVATIVE_COALESCING
|
||||
trespass("not implemented");
|
||||
Uint32 count = 0;
|
||||
#endif // ULTRA_CONSERVATIVE_COALESCING
|
||||
|
||||
if (count < 6 /* FIX: should get the number from the class */) {
|
||||
// Update the interferences vector.
|
||||
if (sourceVector == NULL) {
|
||||
iGraph.setInterferenceVector(source, destinationVector);
|
||||
sourceVector = destinationVector;
|
||||
} else if (destinationVector == NULL)
|
||||
iGraph.setInterferenceVector(destination, sourceVector);
|
||||
else {
|
||||
InterferenceVector* last = NULL;
|
||||
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next)
|
||||
last = v;
|
||||
assert(last);
|
||||
last->next = destinationVector;
|
||||
iGraph.setInterferenceVector(destination, sourceVector);
|
||||
}
|
||||
// Update the interference matrix.
|
||||
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next) {
|
||||
RegisterName* neighbors = v->neighbors;
|
||||
for (Uint32 i = 0; i < v->count; i++) {
|
||||
RegisterName neighbor = findRoot(neighbors[i], coalescedRange);
|
||||
iGraph.setInterference(neighbor, source);
|
||||
iGraph.setInterference(neighbor, destination);
|
||||
}
|
||||
}
|
||||
|
||||
instruction.remove();
|
||||
coalescedRange[source] = destination;
|
||||
removedInstructions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerAllocator.rangeCount = compress(registerAllocator.name2range, coalescedRange, registerAllocator.nameCount, rangeCount);
|
||||
delete newRange;
|
||||
|
||||
return removedInstructions;
|
||||
}
|
||||
|
||||
#endif // _COALESCING_H_
|
||||
283
mozilla/ef/Compiler/RegisterAllocator/Coloring.cpp
Normal file
283
mozilla/ef/Compiler/RegisterAllocator/Coloring.cpp
Normal file
@@ -0,0 +1,283 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NEW_LAURENTM_CODE
|
||||
|
||||
#include "Coloring.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "FastBitSet.h"
|
||||
#include "FastBitMatrix.h"
|
||||
#include "CpuInfo.h"
|
||||
|
||||
bool Coloring::
|
||||
assignRegisters(FastBitMatrix& interferenceMatrix)
|
||||
{
|
||||
PRUint32 *stackPtr = new(pool) PRUint32[vRegManager.count()];
|
||||
|
||||
return select(interferenceMatrix, stackPtr, simplify(interferenceMatrix, stackPtr));
|
||||
}
|
||||
|
||||
PRInt32 Coloring::
|
||||
getLowestSpillCostRegister(FastBitSet& bitset)
|
||||
{
|
||||
PRInt32 lowest = bitset.firstOne();
|
||||
if (lowest != -1)
|
||||
{
|
||||
Flt32 cost = vRegManager.getVirtualRegister(lowest).spillInfo.spillCost;
|
||||
for (PRInt32 r = bitset.nextOne(lowest); r != -1; r = bitset.nextOne(r))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
if (!vReg.spillInfo.infiniteSpillCost && (vReg.spillInfo.spillCost < cost))
|
||||
{
|
||||
cost = vReg.spillInfo.spillCost;
|
||||
lowest = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lowest;
|
||||
}
|
||||
|
||||
PRUint32* Coloring::
|
||||
simplify(FastBitMatrix interferenceMatrix, PRUint32* stackPtr)
|
||||
{
|
||||
// first we construct the sets low and high. low contains all nodes of degree
|
||||
// inferior to the number of register available on the processor. All the
|
||||
// nodes with an high degree and a finite spill cost are placed in high.
|
||||
// Nodes of high degree and infinite spill cost are not included in either sets.
|
||||
|
||||
PRUint32 nRegisters = vRegManager.count();
|
||||
FastBitSet low(pool, nRegisters);
|
||||
FastBitSet high(pool, nRegisters);
|
||||
FastBitSet stack(pool, nRegisters);
|
||||
|
||||
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
|
||||
|
||||
if (vReg.getClass() == vrcStackSlot)
|
||||
{
|
||||
stack.set(i);
|
||||
vReg.colorRegister(nRegisters);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vReg.colorInfo.interferenceDegree < NUMBER_OF_REGISTERS)
|
||||
low.set(i);
|
||||
else // if (!vReg.spillInfo.infiniteSpillCost)
|
||||
high.set(i);
|
||||
|
||||
// Set coloring info.
|
||||
vReg.spillInfo.willSpill = false;
|
||||
|
||||
switch(vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
vReg.colorRegister(LAST_GREGISTER + 1);
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
vReg.colorRegister(LAST_FPREGISTER + 1);
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false); // Cannot happen.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// push the stack registers
|
||||
PRInt32 j;
|
||||
for (j = stack.firstOne(); j != -1; j = stack.nextOne(j))
|
||||
*stackPtr++ = j;
|
||||
|
||||
// simplify
|
||||
while (true)
|
||||
{
|
||||
PRInt32 r;
|
||||
while ((r = getLowestSpillCostRegister(low)) != -1)
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
|
||||
/* update low and high */
|
||||
FastBitSet inter(interferenceMatrix.getRow(r), nRegisters);
|
||||
for (j = inter.firstOne(); j != -1; j = inter.nextOne(j))
|
||||
{
|
||||
VirtualRegister& neighbor = vRegManager.getVirtualRegister(j);
|
||||
// if the new interference degree of one of his neighbor becomes
|
||||
// NUMBER_OF_REGISTERS - 1 then it is added to the set 'low'.
|
||||
|
||||
PRUint32 maxInterference = 0;
|
||||
switch (neighbor.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
maxInterference = NUMBER_OF_GREGISTERS;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
maxInterference = NUMBER_OF_FPREGISTERS;
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false);
|
||||
}
|
||||
if ((vRegManager.getVirtualRegister(j).colorInfo.interferenceDegree-- == maxInterference))
|
||||
{
|
||||
high.clear(j);
|
||||
low.set(j);
|
||||
}
|
||||
vReg.colorInfo.interferenceDegree--;
|
||||
interferenceMatrix.clear(r, j);
|
||||
interferenceMatrix.clear(j, r);
|
||||
}
|
||||
low.clear(r);
|
||||
|
||||
// Push this register.
|
||||
*stackPtr++ = r;
|
||||
}
|
||||
if ((r = getLowestSpillCostRegister(high)) != -1)
|
||||
{
|
||||
high.clear(r);
|
||||
low.set(r);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return stackPtr;
|
||||
}
|
||||
|
||||
bool Coloring::
|
||||
select(FastBitMatrix& interferenceMatrix, PRUint32* stackBase, PRUint32* stackPtr)
|
||||
{
|
||||
PRUint32 nRegisters = vRegManager.count();
|
||||
FastBitSet usedRegisters(NUMBER_OF_REGISTERS + 1); // usedRegisters if used for both GR & FPR.
|
||||
FastBitSet preColoredRegisters(NUMBER_OF_REGISTERS + 1);
|
||||
FastBitSet usedStack(nRegisters + 1);
|
||||
bool success = true;
|
||||
Int32 lastUsedSSR = -1;
|
||||
|
||||
// select
|
||||
while (stackPtr != stackBase)
|
||||
{
|
||||
// Pop one register.
|
||||
PRUint32 r = *--stackPtr;
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
|
||||
FastBitSet neighbors(interferenceMatrix.getRow(r), nRegisters);
|
||||
|
||||
if (vReg.getClass() == vrcStackSlot)
|
||||
// Stack slots coloring.
|
||||
{
|
||||
usedStack.clear();
|
||||
|
||||
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
|
||||
usedStack.set(vRegManager.getVirtualRegister(i).getColor());
|
||||
|
||||
Int32 color = usedStack.firstZero();
|
||||
vReg.colorRegister(color);
|
||||
if (color > lastUsedSSR)
|
||||
lastUsedSSR = color;
|
||||
}
|
||||
else
|
||||
// Integer & Floating point register coloring.
|
||||
{
|
||||
usedRegisters.clear();
|
||||
preColoredRegisters.clear();
|
||||
|
||||
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
|
||||
{
|
||||
VirtualRegister& nvReg = vRegManager.getVirtualRegister(i);
|
||||
usedRegisters.set(nvReg.getColor());
|
||||
if (nvReg.isPreColored())
|
||||
preColoredRegisters.set(nvReg.getPreColor());
|
||||
}
|
||||
if (vReg.hasSpecialInterference)
|
||||
usedRegisters |= vReg.specialInterference;
|
||||
|
||||
PRInt8 c = -1;
|
||||
PRInt8 maxColor = 0;
|
||||
PRInt8 firstColor = 0;
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
firstColor = FIRST_GREGISTER;
|
||||
maxColor = LAST_GREGISTER;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
firstColor = FIRST_FPREGISTER;
|
||||
maxColor = LAST_FPREGISTER;
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false);
|
||||
}
|
||||
|
||||
if (vReg.isPreColored())
|
||||
{
|
||||
c = vReg.getPreColor();
|
||||
if (usedRegisters.test(c))
|
||||
c = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (c = usedRegisters.nextZero(firstColor - 1); (c >= 0) && (c <= maxColor) && (preColoredRegisters.test(c));
|
||||
c = usedRegisters.nextZero(c)) {}
|
||||
}
|
||||
|
||||
if ((c >= 0) && (c <= maxColor))
|
||||
{
|
||||
vReg.colorRegister(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
VirtualRegister& stackRegister = vRegManager.newVirtualRegister(vrcStackSlot);
|
||||
vReg.equivalentRegister[vrcStackSlot] = &stackRegister;
|
||||
vReg.spillInfo.willSpill = true;
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (success)
|
||||
{
|
||||
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
if (vReg.getColor() > LAST_GREGISTER)
|
||||
PR_ASSERT(false);
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
#if NUMBER_OF_FPREGISTERS != 0
|
||||
if (vReg.getColor() > LAST_FPREGISTER)
|
||||
PR_ASSERT(false);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
vRegManager.nUsedStackSlots = lastUsedSSR + 1;
|
||||
return success;
|
||||
}
|
||||
#endif // NEW_LAURENTM_CODE
|
||||
284
mozilla/ef/Compiler/RegisterAllocator/Coloring.h
Normal file
284
mozilla/ef/Compiler/RegisterAllocator/Coloring.h
Normal file
@@ -0,0 +1,284 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "SparseSet.h"
|
||||
#include "Spilling.h"
|
||||
#include "Splits.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
template <class RegisterPressure>
|
||||
class Coloring
|
||||
{
|
||||
private:
|
||||
static RegisterName* simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack);
|
||||
static bool select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr);
|
||||
|
||||
public:
|
||||
static bool color(RegisterAllocator& registerAllocator);
|
||||
static void finalColoring(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Coloring<RegisterPressure>::finalColoring(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
RegisterName* color = registerAllocator.color;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
usePtr->setRegisterName(color[name2range[usePtr->getRegisterName()]]);
|
||||
#ifdef DEBUG
|
||||
RegisterID rid = usePtr->getRegisterID();
|
||||
setColoredRegister(rid);
|
||||
usePtr->setRegisterID(rid);
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
definePtr->setRegisterName(color[name2range[definePtr->getRegisterName()]]);
|
||||
#ifdef DEBUG
|
||||
RegisterID rid = definePtr->getRegisterID();
|
||||
setColoredRegister(rid);
|
||||
definePtr->setRegisterID(rid);
|
||||
#endif // DEBUG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coloring<RegisterPressure>::select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* color = new RegisterName[rangeCount];
|
||||
registerAllocator.color = color;
|
||||
|
||||
for (Uint32 r = 1; r < rangeCount; r++)
|
||||
color[r] = RegisterName(6); // FIX;
|
||||
|
||||
// Color the preColored registers.
|
||||
//
|
||||
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
|
||||
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
|
||||
if (machinePtr->id != invalidID) {
|
||||
color[name2range[getName(machinePtr->id)]] = machinePtr->color;
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill preColor range %d as %d\n", name2range[getName(machinePtr->id)], machinePtr->color));
|
||||
}
|
||||
|
||||
SpillCost* cost = registerAllocator.spillCost;
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet& spill = *new(pool) SparseSet(pool, rangeCount);
|
||||
registerAllocator.willSpill = &spill;
|
||||
SparseSet neighborColors(pool, 6); // FIX
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
|
||||
bool coloringFailed = false;
|
||||
while (coloringStackPtr > coloringStack) {
|
||||
RegisterName range = *--coloringStackPtr;
|
||||
|
||||
if (!cost[range].infinite && cost[range].cost < 0) {
|
||||
coloringFailed = true;
|
||||
spill.set(range);
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, will spill.\n", range));
|
||||
} else {
|
||||
neighborColors.clear();
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = vector->count - 1; i >= 0; --i) {
|
||||
RegisterName neighborColor = color[vector->neighbors[i]];
|
||||
if (neighborColor < 6) // FIX
|
||||
neighborColors.set(neighborColor);
|
||||
}
|
||||
|
||||
if (neighborColors.getSize() == 6) { // FIX
|
||||
coloringFailed = true;
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, ", range));
|
||||
|
||||
if (!Splits<RegisterPressure>::findSplit(registerAllocator, color, range)) {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will spill.\n"));
|
||||
spill.set(range);
|
||||
} else
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will split.\n"));
|
||||
} else {
|
||||
for (Uint32 i = 0; i < 6; i++) // FIX
|
||||
if (!neighborColors.test(i)) {
|
||||
fprintf(stdout, "\twill color %d as %d\n", range, i);
|
||||
color[range] = RegisterName(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
if (coloringFailed) {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring failed:\n"));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill spill: "));
|
||||
spill.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
} else {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring succeeded:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\trange %d colored as %d\n", i, color[i]));
|
||||
}
|
||||
#endif
|
||||
|
||||
return !coloringFailed;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
RegisterName* Coloring<RegisterPressure>::simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack)
|
||||
{
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
SpillCost* spillCost = registerAllocator.spillCost;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
|
||||
Uint32* degree = new Uint32[rangeCount];
|
||||
for (RegisterName i = RegisterName(1); i < rangeCount; i = RegisterName(i + 1)) {
|
||||
InterferenceVector* vector = iGraph.getInterferenceVector(i);
|
||||
degree[i] = (vector != NULL) ? vector->count : 0;
|
||||
}
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet low(pool, rangeCount);
|
||||
SparseSet high(pool, rangeCount);
|
||||
SparseSet highInfinite(pool, rangeCount);
|
||||
SparseSet preColored(pool, rangeCount);
|
||||
|
||||
// Get the precolored registers.
|
||||
//
|
||||
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
|
||||
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
|
||||
if (machinePtr->id != invalidID)
|
||||
preColored.set(name2range[getName(machinePtr->id)]);
|
||||
|
||||
// Insert the live ranges in the sets.
|
||||
//
|
||||
for (Uint32 range = 1; range < rangeCount; range++)
|
||||
if (!preColored.test(range))
|
||||
if (degree[range] < 6) // FIX
|
||||
low.set(range);
|
||||
else if (!spillCost[range].infinite)
|
||||
high.set(range);
|
||||
else
|
||||
highInfinite.set(range);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring sets:\n\tlow = "));
|
||||
low.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thigh = "));
|
||||
high.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thighInfinite = "));
|
||||
highInfinite.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tpreColored = "));
|
||||
preColored.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
RegisterName* coloringStackPtr = coloringStack;
|
||||
|
||||
while (low.getSize() != 0 || high.getSize() != 0) {
|
||||
while (low.getSize() != 0) {
|
||||
RegisterName range = RegisterName(low.getOne());
|
||||
low.clear(range);
|
||||
*coloringStackPtr++ = range;
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = (vector->count - 1); i >= 0; --i) {
|
||||
RegisterName neighbor = vector->neighbors[i];
|
||||
degree[neighbor]--;
|
||||
|
||||
if (degree[neighbor] < 6) // FIX
|
||||
if (high.test(neighbor)) {
|
||||
high.clear(neighbor);
|
||||
low.set(neighbor);
|
||||
} else if (highInfinite.test(neighbor)) {
|
||||
highInfinite.clear(neighbor);
|
||||
low.set(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (high.getSize() != 0) {
|
||||
RegisterName best = RegisterName(high.getOne());
|
||||
double bestCost = spillCost[best].cost;
|
||||
double bestDegree = degree[best];
|
||||
|
||||
// Choose the next best candidate.
|
||||
//
|
||||
for (SparseSet::iterator i = high.begin(); !high.done(i); i = high.advance(i)) {
|
||||
RegisterName range = RegisterName(high.get(i));
|
||||
double thisCost = spillCost[range].cost;
|
||||
double thisDegree = degree[range];
|
||||
|
||||
if (thisCost * bestDegree < bestCost * thisDegree) {
|
||||
best = range;
|
||||
bestCost = thisCost;
|
||||
bestDegree = thisDegree;
|
||||
}
|
||||
}
|
||||
|
||||
high.clear(best);
|
||||
low.set(best);
|
||||
}
|
||||
}
|
||||
assert(highInfinite.getSize() == 0);
|
||||
|
||||
delete degree;
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring stack:\n\t"));
|
||||
for (RegisterName* sp = coloringStack; sp < coloringStackPtr; ++sp)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("%d ", *sp));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\n"));
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
return coloringStackPtr;
|
||||
}
|
||||
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coloring<RegisterPressure>::color(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
RegisterName* coloringStack = new RegisterName[registerAllocator.rangeCount];
|
||||
return select(registerAllocator, coloringStack, simplify(registerAllocator, coloringStack));
|
||||
}
|
||||
212
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.cpp
Normal file
212
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
|
||||
#include "DominatorGraph.h"
|
||||
|
||||
DominatorGraph::DominatorGraph(ControlGraph& controlGraph) : controlGraph(controlGraph)
|
||||
{
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
GtoV = new Uint32[nNodes + 1];
|
||||
VtoG = new Uint32[nNodes + 1];
|
||||
|
||||
Uint32 v = 1;
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
VtoG[v] = n;
|
||||
GtoV[n] = v++;
|
||||
}
|
||||
|
||||
// Initialize all the 1-based arrays.
|
||||
//
|
||||
parent = new Uint32[v];
|
||||
semi = new Uint32[v];
|
||||
vertex = new Uint32[v];
|
||||
label = new Uint32[v];
|
||||
size = new Uint32[v];
|
||||
ancestor = new Uint32[v];
|
||||
child = new Uint32[v];
|
||||
dom = new Uint32[v];
|
||||
bucket = new DGLinkedList*[v];
|
||||
|
||||
memset(semi, '\0', v * sizeof(Uint32));
|
||||
memset(bucket, '\0', v * sizeof(DGLinkedList*));
|
||||
|
||||
vCount = v;
|
||||
|
||||
build();
|
||||
|
||||
delete parent;
|
||||
delete semi;
|
||||
delete vertex;
|
||||
delete label;
|
||||
delete size;
|
||||
delete ancestor;
|
||||
delete child;
|
||||
delete dom;
|
||||
delete bucket;
|
||||
}
|
||||
|
||||
Uint32 DominatorGraph::DFS(Uint32 vx, Uint32 n)
|
||||
{
|
||||
semi[vx] = ++n;
|
||||
vertex[n] = label[vx] = vx;
|
||||
ancestor[vx] = child[vx] = 0;
|
||||
size[vx] = 1;
|
||||
|
||||
|
||||
ControlNode& node = *controlGraph.dfsList[VtoG[vx]];
|
||||
ControlEdge* successorEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorPtr = node.getSuccessorsBegin(); successorPtr < successorEnd; successorPtr++) {
|
||||
Uint32 w = GtoV[successorPtr->getTarget().dfsNum];
|
||||
if (semi[w] == 0) {
|
||||
parent[w] = vx;
|
||||
n = DFS(w, n);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void DominatorGraph::LINK(Uint32 vx, Uint32 w)
|
||||
{
|
||||
Uint32 s = w;
|
||||
|
||||
while (semi[label[w]] < semi[label[child[s]]]) {
|
||||
if (size[s] + size[child[child[s]]] >= (size[child[s]] << 1)) {
|
||||
ancestor[child[s]] = s;
|
||||
child[s] = child[child[s]];
|
||||
} else {
|
||||
size[child[s]] = size[s];
|
||||
s = ancestor[s] = child[s];
|
||||
}
|
||||
}
|
||||
label[s] = label[w];
|
||||
size[vx] += size[w];
|
||||
if(size[vx] < (size[w] << 1)) {
|
||||
Uint32 t = s;
|
||||
s = child[vx];
|
||||
child[vx] = t;
|
||||
}
|
||||
while( s != 0 ) {
|
||||
ancestor[s] = vx;
|
||||
s = child[s];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DominatorGraph::COMPRESS(Uint32 vx)
|
||||
{
|
||||
if(ancestor[ancestor[vx]] != 0) {
|
||||
COMPRESS(ancestor[vx]);
|
||||
if(semi[label[ancestor[vx]]] < semi[label[vx]])
|
||||
label[vx] = label[ancestor[vx]];
|
||||
ancestor[vx] = ancestor[ancestor[vx]];
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 DominatorGraph::EVAL(Uint32 vx)
|
||||
{
|
||||
if(ancestor[vx] == 0)
|
||||
return label[vx];
|
||||
COMPRESS(vx);
|
||||
return (semi[label[ancestor[vx]]] >= semi[label[vx]]) ? label[vx] : label[ancestor[vx]];
|
||||
}
|
||||
|
||||
void DominatorGraph::build()
|
||||
{
|
||||
Uint32 n = DFS(GtoV[0], 0);
|
||||
size[0] = label[0] = semi[0];
|
||||
|
||||
for (Uint32 i = n; i >= 2; i--) {
|
||||
Uint32 w = vertex[i];
|
||||
|
||||
ControlNode& node = *controlGraph.dfsList[VtoG[w]];
|
||||
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
|
||||
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p)) {
|
||||
Uint32 vx = GtoV[predecessors.get(p).getSource().dfsNum];
|
||||
Uint32 u = EVAL(vx);
|
||||
|
||||
if(semi[u] < semi[w])
|
||||
semi[w] = semi[u];
|
||||
}
|
||||
|
||||
DGLinkedList* elem = new DGLinkedList();
|
||||
elem->next = bucket[vertex[semi[w]]];
|
||||
elem->index = w;
|
||||
bucket[vertex[semi[w]]] = elem;
|
||||
|
||||
LINK(parent[w], w);
|
||||
|
||||
elem = bucket[parent[w]];
|
||||
while(elem != NULL) {
|
||||
Uint32 vx = elem->index;
|
||||
Uint32 u = EVAL(vx);
|
||||
dom[vx] = (semi[u] < semi[vx]) ? u : parent[w];
|
||||
elem = elem->next;
|
||||
}
|
||||
}
|
||||
|
||||
memset(size, '\0', n * sizeof(Uint32));
|
||||
Pool& pool = controlGraph.pool;
|
||||
nodes = new(pool) DGNode[n];
|
||||
|
||||
for(Uint32 j = 2; j <= n; j++) {
|
||||
Uint32 w = vertex[j];
|
||||
Uint32 d = dom[w];
|
||||
if(d != vertex[semi[w]]) {
|
||||
d = dom[d];
|
||||
dom[w] = d;
|
||||
}
|
||||
size[d]++;
|
||||
}
|
||||
dom[GtoV[0]] = 0;
|
||||
|
||||
for (Uint32 k = 1; k <= n; k++) {
|
||||
DGNode& node = nodes[VtoG[k]];
|
||||
Uint32 count = size[k];
|
||||
node.successorsEnd = node.successorsBegin = (count) ? new(pool) Uint32[count] : (Uint32*) 0;
|
||||
}
|
||||
|
||||
for (Uint32 l = 2; l <= n; l++)
|
||||
*(nodes[VtoG[dom[l]]].successorsEnd)++ = VtoG[l];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void DominatorGraph::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Dominator Graph:\n"));
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
for (Uint32 i = 0; i < nNodes; i++) {
|
||||
DGNode& node = nodes[i];
|
||||
if (node.successorsBegin != node.successorsEnd) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tN%d dominates ", i));
|
||||
for (Uint32* successorsPtr = node.successorsBegin; successorsPtr < node.successorsEnd; successorsPtr++)
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d ", *successorsPtr));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
|
||||
|
||||
80
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.h
Normal file
80
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DOMINATOR_GRAPH_H_
|
||||
#define _DOMINATOR_GRAPH_H_
|
||||
|
||||
#include "LogModule.h"
|
||||
|
||||
class ControlGraph;
|
||||
|
||||
struct DGNode
|
||||
{
|
||||
Uint32* successorsBegin;
|
||||
Uint32* successorsEnd;
|
||||
};
|
||||
|
||||
struct DGLinkedList
|
||||
{
|
||||
DGLinkedList* next;
|
||||
Uint32 index;
|
||||
};
|
||||
|
||||
class DominatorGraph
|
||||
{
|
||||
private:
|
||||
|
||||
ControlGraph& controlGraph;
|
||||
|
||||
Uint32 vCount;
|
||||
|
||||
Uint32* VtoG;
|
||||
Uint32* GtoV;
|
||||
Uint32* parent;
|
||||
Uint32* semi;
|
||||
Uint32* vertex;
|
||||
Uint32* label;
|
||||
Uint32* size;
|
||||
Uint32* ancestor;
|
||||
Uint32* child;
|
||||
Uint32* dom;
|
||||
DGLinkedList** bucket;
|
||||
DGNode* nodes;
|
||||
|
||||
private:
|
||||
|
||||
void build();
|
||||
|
||||
Uint32 DFS(Uint32 vx, Uint32 n);
|
||||
void LINK(Uint32 vx, Uint32 w);
|
||||
void COMPRESS(Uint32 vx);
|
||||
Uint32 EVAL(Uint32 vx);
|
||||
|
||||
public:
|
||||
|
||||
DominatorGraph(ControlGraph& controlGraph);
|
||||
|
||||
Uint32* getSuccessorsBegin(Uint32 n) const {return nodes[n].successorsBegin;}
|
||||
Uint32* getSuccessorsEnd(Uint32 n) const {return nodes[n].successorsEnd;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
#endif // _DOMINATOR_GRAPH_H_
|
||||
20
mozilla/ef/Compiler/RegisterAllocator/HashSet.cpp
Normal file
20
mozilla/ef/Compiler/RegisterAllocator/HashSet.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashSet.h"
|
||||
97
mozilla/ef/Compiler/RegisterAllocator/HashSet.h
Normal file
97
mozilla/ef/Compiler/RegisterAllocator/HashSet.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _HASH_SET_H_
|
||||
#define _HASH_SET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include <string.h>
|
||||
|
||||
struct HashSetElement
|
||||
{
|
||||
Uint32 index;
|
||||
HashSetElement* next;
|
||||
};
|
||||
|
||||
class HashSet
|
||||
{
|
||||
private:
|
||||
|
||||
static const hashSize = 64;
|
||||
|
||||
// Return the hash code for the given element index.
|
||||
static Uint32 getHashCode(Uint32 index) {return index & (hashSize - 1);} // Could be better !
|
||||
|
||||
private:
|
||||
|
||||
Pool& allocationPool;
|
||||
HashSetElement** bucket;
|
||||
HashSetElement* free;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
HashSet(const HashSet&);
|
||||
// No copy operator.
|
||||
void operator = (const HashSet&);
|
||||
|
||||
public:
|
||||
|
||||
// Create a new HashSet.
|
||||
inline HashSet(Pool& pool, Uint32 universeSize);
|
||||
|
||||
// Clear the hashset.
|
||||
void clear();
|
||||
// Clear the element for the given index.
|
||||
void clear(Uint32 index);
|
||||
// Set the element for the given index.
|
||||
void set(Uint32 index);
|
||||
// Return true if the element at index is a member.
|
||||
bool test(Uint32 index) const;
|
||||
// Union with the given hashset.
|
||||
inline void or(const HashSet& set);
|
||||
// Intersection with the given hashset.
|
||||
inline void and(const HashSet& set);
|
||||
// Difference with the given hashset.
|
||||
inline void difference(const HashSet& set);
|
||||
|
||||
// Logical operators.
|
||||
HashSet& operator |= (const HashSet& set) {or(set); return *this;}
|
||||
HashSet& operator &= (const HashSet& set) {and(set); return *this;}
|
||||
HashSet& operator -= (const HashSet& set) {difference(set); return *this;}
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef HashSetElement* iterator;
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const;
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const;
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos == NULL;}
|
||||
};
|
||||
|
||||
|
||||
inline HashSet::HashSet(Pool& pool, Uint32 /*universeSize*/)
|
||||
: allocationPool(pool), free(NULL)
|
||||
{
|
||||
bucket = new(pool) HashSetElement*[hashSize];
|
||||
memset(bucket, '\0', sizeof(HashSetElement*));
|
||||
}
|
||||
|
||||
#endif // _HASH_SET_H_
|
||||
213
mozilla/ef/Compiler/RegisterAllocator/IndexedPool.h
Normal file
213
mozilla/ef/Compiler/RegisterAllocator/IndexedPool.h
Normal file
@@ -0,0 +1,213 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _INDEXED_POOL_H_
|
||||
#define _INDEXED_POOL_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedPool<IndexedObjectSubclass> is an indexed pool of objects. The
|
||||
// template parameter 'IndexedObjectSubclass' must be a subclass of the struct
|
||||
// IndexedObject.
|
||||
//
|
||||
// When the indexed pool is ask to allocate and initialize a new object (using
|
||||
// the operator new(anIndexedPool) it will zero the memory used to store the
|
||||
// object and initialize the field 'index' of this object to its position in
|
||||
// the pool.
|
||||
//
|
||||
// An object allocated by the indexed pool can be freed by calling the method
|
||||
// IndexedPool::release(IndexedElement& objectIndex).
|
||||
//
|
||||
// example:
|
||||
//
|
||||
// IndexedPool<IndexedElement> elementPool;
|
||||
//
|
||||
// IndexedElement& element1 = *new(elementPool) IndexedElement();
|
||||
// IndexedElement& element2 = *new(elementPool) IndexedElement();
|
||||
//
|
||||
// indexedPool.release(element1);
|
||||
// IndexedElement& element3 = *new(elementPool) IndexedElement();
|
||||
//
|
||||
// At this point element1 is no longer a valid object, element2 is at
|
||||
// index 2 and element3 is at index 1.
|
||||
//
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedObject -
|
||||
//
|
||||
|
||||
template<class Object>
|
||||
struct IndexedObject
|
||||
{
|
||||
Uint32 index; // Index in the pool.
|
||||
Object* next; // Used to link IndexedObject together.
|
||||
|
||||
Uint32 getIndex() {return index;}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedPool<IndexedObject> -
|
||||
//
|
||||
|
||||
template <class IndexedObject>
|
||||
class IndexedPool
|
||||
{
|
||||
private:
|
||||
|
||||
static const blockSize = 4; // Size of one block.
|
||||
|
||||
Uint32 nBlocks; // Number of blocks in the pool.
|
||||
IndexedObject** block; // Array of block pointers.
|
||||
IndexedObject* freeObjects; // Chained list of free IndexedObjects.
|
||||
Uint32 nextIndex; // Index of the next free object in the last block.
|
||||
|
||||
private:
|
||||
|
||||
void allocateAnotherBlock();
|
||||
IndexedObject& newObject();
|
||||
|
||||
public:
|
||||
|
||||
IndexedPool() : nBlocks(0), block(NULL), freeObjects(NULL), nextIndex(1) {}
|
||||
~IndexedPool();
|
||||
|
||||
IndexedObject& get(Uint32 index) const;
|
||||
void release(IndexedObject& object);
|
||||
|
||||
void setSize(Uint32 size) {assert(size < nextIndex); nextIndex = size;}
|
||||
|
||||
// Return the universe size.
|
||||
Uint32 getSize() {return nextIndex;}
|
||||
|
||||
friend void* operator new(size_t, IndexedPool<IndexedObject>& pool); // Needs to call newObject().
|
||||
};
|
||||
|
||||
// Free all the memory allocated for this object.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedPool<IndexedObject>::~IndexedPool()
|
||||
{
|
||||
for (Uint32 n = 0; n < nBlocks; n++)
|
||||
free(&((IndexedObject **) &block[n][n*blockSize])[-(n + 1)]);
|
||||
}
|
||||
|
||||
// Release the given. This object will be iserted in the chained
|
||||
// list of free IndexedObjects. To minimize the fragmentation the chained list
|
||||
// is ordered by ascending indexes.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void IndexedPool<IndexedObject>::release(IndexedObject& object)
|
||||
{
|
||||
Uint32 index = object.index;
|
||||
IndexedObject* list = freeObjects;
|
||||
|
||||
assert(&object == &get(index)); // Make sure that object is owned by this pool.
|
||||
|
||||
if (list == NULL) { // The list is empty.
|
||||
freeObjects = &object;
|
||||
object.next = NULL;
|
||||
} else { // The list contains at least 1 element.
|
||||
if (index < list->index) { // insert as first element.
|
||||
freeObjects = &object;
|
||||
object.next = list;
|
||||
} else { // Find this object's place.
|
||||
while ((list->next) != NULL && (list->next->index < index))
|
||||
list = list->next;
|
||||
|
||||
object.next = list->next;
|
||||
list->next = &object;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Sanity check to be sure that the list is correctly ordered.
|
||||
for (IndexedObject* obj = freeObjects; obj != NULL; obj = obj->next)
|
||||
if (obj->next != NULL)
|
||||
assert(obj->index < obj->next->index);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create a new block of IndexedObjects. We will allocate the memory to
|
||||
// store IndexedPool::blockSize IndexedObject and the new Array of block
|
||||
// pointers.
|
||||
// The newly created IndexedObjects will not be initialized.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void IndexedPool<IndexedObject>::allocateAnotherBlock()
|
||||
{
|
||||
void* memory = (void *) malloc((nBlocks + 1) * sizeof(Uint32) + blockSize * sizeof(IndexedObject));
|
||||
|
||||
memcpy(memory, block, nBlocks * sizeof(Uint32));
|
||||
|
||||
block = (IndexedObject **) memory;
|
||||
IndexedObject* objects = (IndexedObject *) &block[nBlocks + 1];
|
||||
|
||||
block[nBlocks] = &objects[-(nBlocks * blockSize)];
|
||||
nBlocks++;
|
||||
}
|
||||
|
||||
// Return the IndexedObject at the position 'index' in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedObject& IndexedPool<IndexedObject>::get(Uint32 index) const
|
||||
{
|
||||
Uint32 blockIndex = index / blockSize;
|
||||
assert(blockIndex < nBlocks);
|
||||
|
||||
return block[blockIndex][index];
|
||||
}
|
||||
|
||||
// Return the reference of an unused object in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedObject& IndexedPool<IndexedObject>::newObject()
|
||||
{
|
||||
if (freeObjects != NULL) {
|
||||
IndexedObject& newObject = *freeObjects;
|
||||
freeObjects = newObject.next;
|
||||
return newObject;
|
||||
}
|
||||
|
||||
Uint32 nextIndex = this->nextIndex++;
|
||||
Uint32 blockIndex = nextIndex / blockSize;
|
||||
|
||||
while (blockIndex >= nBlocks)
|
||||
allocateAnotherBlock();
|
||||
|
||||
IndexedObject& newObject = block[blockIndex][nextIndex];
|
||||
newObject.index = nextIndex;
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
// Return the address of the next unsused object in the given
|
||||
// indexed pool. The field index of the newly allocated object
|
||||
// will be initialized to the corresponding index of this object
|
||||
// in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void* operator new(size_t size, IndexedPool<IndexedObject>& pool)
|
||||
{
|
||||
assert(size == sizeof(IndexedObject));
|
||||
return (void *) &pool.newObject();
|
||||
}
|
||||
|
||||
#endif // _INDEXED_POOL_H_
|
||||
258
mozilla/ef/Compiler/RegisterAllocator/InterferenceGraph.h
Normal file
258
mozilla/ef/Compiler/RegisterAllocator/InterferenceGraph.h
Normal file
@@ -0,0 +1,258 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _INTERFERENCE_GRAPH_H_
|
||||
#define _INTERFERENCE_GRAPH_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "Primitives.h"
|
||||
#include "Instruction.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "SparseSet.h"
|
||||
#include <string.h>
|
||||
|
||||
struct InterferenceVector
|
||||
{
|
||||
Uint32 count;
|
||||
InterferenceVector* next;
|
||||
RegisterName* neighbors;
|
||||
|
||||
InterferenceVector() : count(0), next(NULL) {}
|
||||
};
|
||||
|
||||
class RegisterAllocator;
|
||||
|
||||
template <class RegisterPressure>
|
||||
class InterferenceGraph
|
||||
{
|
||||
private:
|
||||
|
||||
RegisterAllocator& registerAllocator;
|
||||
|
||||
RegisterPressure::Set* interferences;
|
||||
InterferenceVector** vector;
|
||||
Uint32* offset;
|
||||
Uint32 rangeCount;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
InterferenceGraph(const InterferenceGraph&);
|
||||
// No copy operator.
|
||||
void operator = (const InterferenceGraph&);
|
||||
|
||||
// Check if reg is a member of the universe.
|
||||
void checkMember(RegisterName name) {assert(name < rangeCount);}
|
||||
// Return the edge index for the interference between name1 and name2.
|
||||
Uint32 getEdgeIndex(RegisterName name1, RegisterName name2);
|
||||
|
||||
public:
|
||||
InterferenceGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
|
||||
|
||||
// Calculate the interferences.
|
||||
void build();
|
||||
// Return true if reg1 and reg2 interfere.
|
||||
bool interfere(RegisterName name1, RegisterName name2);
|
||||
// Return the interference vector for the given register or NULL if there is none.
|
||||
InterferenceVector* getInterferenceVector(RegisterName name) {return vector[name];}
|
||||
// Set the interference between name1 and name2.
|
||||
void setInterference(RegisterName name1, RegisterName name2);
|
||||
// Set the interference vector for the given register.
|
||||
void setInterferenceVector(RegisterName name, InterferenceVector* v) {vector[name] = v;}
|
||||
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the interferences.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::build()
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
this->rangeCount = rangeCount;
|
||||
|
||||
// Initialize the structures.
|
||||
//
|
||||
offset = new(pool) Uint32[rangeCount + 1];
|
||||
vector = new(pool) InterferenceVector*[rangeCount];
|
||||
memset(vector, '\0', sizeof(InterferenceVector*) * rangeCount);
|
||||
|
||||
Uint32 o = 0;
|
||||
offset[0] = 0;
|
||||
for (Uint32 i = 1; i <= rangeCount; ++i) {
|
||||
offset[i] = o;
|
||||
o += i;
|
||||
}
|
||||
|
||||
interferences = new(pool) RegisterPressure::Set(pool, (rangeCount * rangeCount) / 2);
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
LivenessInfo<RegisterPressure> liveness = Liveness<RegisterPressure>::analysis(controlGraph, rangeCount, name2range);
|
||||
registerAllocator.liveness = liveness;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
currentLive = liveness.liveOut[n];
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
// Handle the copy instruction to avoid unnecessary interference between the 2 registers.
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
|
||||
}
|
||||
|
||||
// Create the interferences.
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName define = name2range[definePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator e = currentLive.begin(); !currentLive.done(e); e = currentLive.advance(e)) {
|
||||
RegisterName live = RegisterName(currentLive.get(e));
|
||||
|
||||
if ((live != define) && !interfere(live, define) && registerAllocator.canInterfere(live, define)) {
|
||||
|
||||
if (vector[define] == NULL)
|
||||
vector[define] = new(pool) InterferenceVector();
|
||||
vector[define]->count++;
|
||||
|
||||
if (vector[live] == NULL)
|
||||
vector[live] = new(pool) InterferenceVector();
|
||||
vector[live]->count++;
|
||||
|
||||
setInterference(live, define);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now update the liveness.
|
||||
//
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
currentLive.set(name2range[usePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate the memory to store the interferences.
|
||||
//
|
||||
for (Uint32 e = 0; e < rangeCount; e++)
|
||||
if (vector[e] != NULL) {
|
||||
InterferenceVector& v = *vector[e];
|
||||
v.neighbors = new(pool) RegisterName[v.count];
|
||||
v.count = 0;
|
||||
}
|
||||
|
||||
// Initialize the edges.
|
||||
//
|
||||
if (RegisterPressure::Set::isOrdered()) {
|
||||
RegisterName name1 = RegisterName(0);
|
||||
|
||||
for (RegisterPressure::Set::iterator i = interferences->begin(); !interferences->done(i); i = interferences->advance(i)) {
|
||||
Uint32 interferenceIndex = interferences->get(i);
|
||||
|
||||
while(interferenceIndex >= offset[name1 + 1])
|
||||
name1 = RegisterName(name1 + 1);
|
||||
|
||||
assert((interferenceIndex >= offset[name1]) && (interferenceIndex < offset[name1 + 1]));
|
||||
|
||||
RegisterName name2 = RegisterName(interferenceIndex - offset[name1]);
|
||||
|
||||
assert(interfere(name1, name2));
|
||||
|
||||
InterferenceVector& vector1 = *vector[name1];
|
||||
vector1.neighbors[vector1.count++] = name2;
|
||||
|
||||
InterferenceVector& vector2 = *vector[name2];
|
||||
vector2.neighbors[vector2.count++] = name1;
|
||||
}
|
||||
} else {
|
||||
trespass("not Implemented"); // FIX: need one more pass to initialize the vectors.
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
Uint32 InterferenceGraph<RegisterPressure>::getEdgeIndex(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
checkMember(name1); checkMember(name2);
|
||||
assert(name1 != name2); // This is not possible.
|
||||
return (name1 < name2) ? offset[name2] + name1 : offset[name1] + name2;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::setInterference(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
interferences->set(getEdgeIndex(name1, name2));
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool InterferenceGraph<RegisterPressure>::interfere(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
return interferences->test(getEdgeIndex(name1, name2));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Vectors:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
if (vector[i] != NULL) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tvr%d: (", i));
|
||||
for (InterferenceVector* v = vector[i]; v != NULL; v = v->next)
|
||||
for (Uint32 j = 0; j < v->count; j++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", v->neighbors[j]));
|
||||
if (v->next != NULL || j != (v->count - 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (","));
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (")\n"));
|
||||
}
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Matrix:\n"));
|
||||
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
|
||||
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && interfere(name1, name2)) ? '1' : '0'));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _INTERFERENCE_GRAPH_H_
|
||||
87
mozilla/ef/Compiler/RegisterAllocator/LiveRange.h
Normal file
87
mozilla/ef/Compiler/RegisterAllocator/LiveRange.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVE_RANGE_H_
|
||||
#define _LIVE_RANGE_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Primitives.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct LiveRange
|
||||
{
|
||||
static void build(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRange<RegisterPressure>::build(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
// Intialize the lookup table.
|
||||
//
|
||||
Uint32 nameCount = registerAllocator.nameCount;
|
||||
RegisterName* nameTable = new(registerAllocator.pool) RegisterName[2*nameCount];
|
||||
RegisterName* rangeName = &nameTable[nameCount];
|
||||
|
||||
init(rangeName, nameCount);
|
||||
|
||||
// Walk the graph.
|
||||
//
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
SparseSet destination(registerAllocator.pool, nameCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
|
||||
destination.clear();
|
||||
for (InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
Instruction& phiNode = phiNodes.get(i);
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
destination.set(findRoot(phiNode.getInstructionDefineBegin()[0].getRegisterName(), rangeName));
|
||||
}
|
||||
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
RegisterName destinationName = phiNode.getInstructionDefineBegin()[0].getRegisterName();
|
||||
RegisterName destinationRoot = findRoot(destinationName, rangeName);
|
||||
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
|
||||
assert(usePtr->isRegister());
|
||||
RegisterName sourceName = usePtr->getRegisterName();
|
||||
RegisterName sourceRoot = findRoot(sourceName, rangeName);
|
||||
|
||||
if (sourceRoot != destinationRoot && !destination.test(sourceRoot))
|
||||
rangeName[sourceRoot] = destinationRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerAllocator.rangeCount = compress(registerAllocator.name2range, rangeName, nameCount, nameCount);
|
||||
}
|
||||
|
||||
#endif // _LIVE_RANGE_H_
|
||||
163
mozilla/ef/Compiler/RegisterAllocator/LiveRangeGraph.h
Normal file
163
mozilla/ef/Compiler/RegisterAllocator/LiveRangeGraph.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVE_RANGE_GRAPH_
|
||||
#define _LIVE_RANGE_GRAPH_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
class RegisterAllocator;
|
||||
|
||||
template <class RegisterPressure>
|
||||
class LiveRangeGraph
|
||||
{
|
||||
private:
|
||||
|
||||
RegisterAllocator& registerAllocator;
|
||||
|
||||
RegisterPressure::Set* edges;
|
||||
Uint32 rangeCount;
|
||||
|
||||
public:
|
||||
//
|
||||
//
|
||||
LiveRangeGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
|
||||
|
||||
//
|
||||
//
|
||||
void build();
|
||||
|
||||
//
|
||||
//
|
||||
void addEdge(RegisterName name1, RegisterName name2);
|
||||
|
||||
//
|
||||
//
|
||||
bool haveEdge(RegisterName name1, RegisterName name2);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
//
|
||||
//
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::build()
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
this->rangeCount = rangeCount;
|
||||
|
||||
edges = new(pool) RegisterPressure::Set(pool, rangeCount * rangeCount);
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
LivenessInfo<RegisterPressure>& liveness = registerAllocator.liveness;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
currentLive = liveness.liveOut[n];
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName define = name2range[definePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
|
||||
RegisterName live = RegisterName(currentLive.get(l));
|
||||
if (define != live && registerAllocator.canInterfere(define, live))
|
||||
addEdge(define, live);
|
||||
}
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
currentLive.set(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName use = name2range[usePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
|
||||
RegisterName live = RegisterName(currentLive.get(l));
|
||||
if (use != live && registerAllocator.canInterfere(use, live))
|
||||
addEdge(use, live);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::addEdge(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
assert(name1 != name2);
|
||||
edges->set(name1 * rangeCount + name2);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool LiveRangeGraph<RegisterPressure>::haveEdge(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
assert(name1 != name2);
|
||||
return edges->test(name1 * rangeCount + name2);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Live ranges graph:\n"));
|
||||
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
|
||||
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && haveEdge(name1, name2)) ? '1' : '0'));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _LIVE_RANGE_GRAPH_
|
||||
21
mozilla/ef/Compiler/RegisterAllocator/Liveness.cpp
Normal file
21
mozilla/ef/Compiler/RegisterAllocator/Liveness.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Liveness.h"
|
||||
|
||||
301
mozilla/ef/Compiler/RegisterAllocator/Liveness.h
Normal file
301
mozilla/ef/Compiler/RegisterAllocator/Liveness.h
Normal file
@@ -0,0 +1,301 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVENESS_H_
|
||||
#define _LIVENESS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// LivenessInfo -
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct LivenessInfo
|
||||
{
|
||||
RegisterPressure::Set* liveIn;
|
||||
RegisterPressure::Set* liveOut;
|
||||
DEBUG_LOG_ONLY(Uint32 size);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Liveness
|
||||
//
|
||||
// The liveness is defined by the following data-flow equations:
|
||||
//
|
||||
// LiveIn(n) = LocalLive(n) U (LiveOut(n) - Killed(n)).
|
||||
// LiveOut(n) = U LiveIn(s) (s a successor of n).
|
||||
//
|
||||
// where LocalLive(n) is the set of used registers in the block n, Killed(n)
|
||||
// is the set of defined registers in the block n, LiveIn(n) is the set of
|
||||
// live registers at the begining of the block n and LiveOut(n) is the set
|
||||
// of live registers at the end of the block n.
|
||||
//
|
||||
//
|
||||
// We will compute the liveness analysis in two stages:
|
||||
//
|
||||
// 1- Build LocalLive(n) (wich is an approximation of LiveIn(n)) and Killed(n)
|
||||
// for each block n.
|
||||
// 2- Perform a backward data-flow analysis to propagate the liveness information
|
||||
// through the entire control-flow graph.
|
||||
//
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Liveness
|
||||
{
|
||||
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range);
|
||||
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 nameCount);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Allocate the temporary sets.
|
||||
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
|
||||
// Allocate the globals sets.
|
||||
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
|
||||
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
|
||||
//
|
||||
for (Uint32 n = 0; n < (nNodes - 1); n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLocalLive = liveIn[n];
|
||||
RegisterPressure::Set& currentKilled = killed[n];
|
||||
|
||||
// Find the instructions contributions to the sets LocalLive and Killed.
|
||||
//
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
Uint32 index = name2range[usePtr->getRegisterName()];
|
||||
|
||||
if (!currentKilled.test(index))
|
||||
currentLocalLive.set(index);
|
||||
}
|
||||
|
||||
// If a Virtualregister is 'defined' then we add it to the set Killed.
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentKilled.set(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
|
||||
// control-flow graph.
|
||||
//
|
||||
RegisterPressure::Set temp(pool, rangeCount);
|
||||
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
// For all nodes is this graph except the endNode.
|
||||
for (Int32 n = (nNodes - 2); n >= 0; n--) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLiveIn = liveIn[n];
|
||||
RegisterPressure::Set& currentLiveOut = liveOut[n];
|
||||
|
||||
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
|
||||
// temp will be the new LiveOut(n).
|
||||
Uint32 nSuccessors = node.nSuccessors();
|
||||
if (nSuccessors != 0) {
|
||||
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
|
||||
for (Uint32 s = 1; s < nSuccessors; s++)
|
||||
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
|
||||
} else
|
||||
temp.clear();
|
||||
|
||||
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
|
||||
// new LiveIn(n).
|
||||
if (currentLiveOut != temp) {
|
||||
currentLiveOut = temp;
|
||||
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
|
||||
temp |= currentLiveIn;
|
||||
|
||||
if (currentLiveIn != temp) {
|
||||
currentLiveIn = temp;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(changed);
|
||||
|
||||
LivenessInfo<RegisterPressure> liveness;
|
||||
liveness.liveIn = liveIn;
|
||||
liveness.liveOut = liveOut;
|
||||
DEBUG_LOG_ONLY(liveness.size = nNodes);
|
||||
return liveness;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 nameCount)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Allocate the temporary sets.
|
||||
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
RegisterPressure::Set* usedByPhiNodes = NULL;
|
||||
|
||||
// Allocate the globals sets.
|
||||
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
|
||||
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
|
||||
//
|
||||
for (Uint32 n = 0; n < (nNodes - 1); n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLocalLive = liveIn[n];
|
||||
RegisterPressure::Set& currentKilled = killed[n];
|
||||
|
||||
InstructionList& phiNodes = node.getPhiNodeInstructions();
|
||||
|
||||
if ((usedByPhiNodes == NULL) && !phiNodes.empty())
|
||||
usedByPhiNodes = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
InstructionDefine& define = phiNode.getInstructionDefineBegin()[0];
|
||||
currentKilled.set(define.getRegisterName());
|
||||
|
||||
typedef DoublyLinkedList<ControlEdge> ControlEdgeList;
|
||||
const ControlEdgeList& predecessors = node.getPredecessors();
|
||||
ControlEdgeList::iterator p = predecessors.begin();
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++, p = predecessors.advance(p))
|
||||
if (usePtr->isRegister())
|
||||
usedByPhiNodes[predecessors.get(p).getSource().dfsNum].set(usePtr->getRegisterName());
|
||||
}
|
||||
|
||||
// Find the instructions contributions to the sets LocalLive and Killed.
|
||||
//
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
Uint32 index = usePtr->getRegisterName();
|
||||
|
||||
if (!currentKilled.test(index))
|
||||
currentLocalLive.set(index);
|
||||
}
|
||||
|
||||
// If a Virtualregister is 'defined' then we add it to the set Killed.
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentKilled.set(definePtr->getRegisterName());
|
||||
}
|
||||
}
|
||||
|
||||
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
|
||||
// control-flow graph.
|
||||
//
|
||||
RegisterPressure::Set temp(pool, nameCount);
|
||||
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
// For all nodes is this graph except the endNode.
|
||||
for (Int32 n = (nNodes - 2); n >= 0; n--) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLiveIn = liveIn[n];
|
||||
RegisterPressure::Set& currentLiveOut = liveOut[n];
|
||||
|
||||
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
|
||||
// temp will be the new LiveOut(n).
|
||||
Uint32 nSuccessors = node.nSuccessors();
|
||||
if (nSuccessors != 0) {
|
||||
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
|
||||
for (Uint32 s = 1; s < nSuccessors; s++)
|
||||
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
|
||||
} else
|
||||
temp.clear();
|
||||
|
||||
// Insert the phiNodes contribution.
|
||||
if (usedByPhiNodes != NULL)
|
||||
temp |= usedByPhiNodes[n];
|
||||
|
||||
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
|
||||
// new LiveIn(n).
|
||||
if (currentLiveOut != temp) {
|
||||
currentLiveOut = temp;
|
||||
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
|
||||
temp |= currentLiveIn;
|
||||
|
||||
if (currentLiveIn != temp) {
|
||||
currentLiveIn = temp;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(changed);
|
||||
|
||||
LivenessInfo<RegisterPressure> liveness;
|
||||
liveness.liveIn = liveIn;
|
||||
liveness.liveOut = liveOut;
|
||||
DEBUG_LOG_ONLY(liveness.size = nNodes);
|
||||
return liveness;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void LivenessInfo<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
for (Uint32 n = 0; n < size; n++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Node N%d:\n\tliveIn = ", n));
|
||||
liveIn[n].printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tliveOut = "));
|
||||
liveOut[n].printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _LIVENESS_H_
|
||||
40
mozilla/ef/Compiler/RegisterAllocator/Makefile
Normal file
40
mozilla/ef/Compiler/RegisterAllocator/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
MODULE_NAME = RegisterAllocator
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
INCLUDES += \
|
||||
-I$(DEPTH)/Utilities/General \
|
||||
-I$(DEPTH)/Utilities/zlib \
|
||||
-I$(DEPTH)/Runtime/ClassReader \
|
||||
-I$(DEPTH)/Runtime/NativeMethods \
|
||||
-I$(DEPTH)/Runtime/System \
|
||||
-I$(DEPTH)/Runtime/ClassInfo \
|
||||
-I$(DEPTH)/Runtime/FileReader \
|
||||
-I$(DEPTH)/Compiler/PrimitiveGraph \
|
||||
-I$(DEPTH)/Compiler/FrontEnd \
|
||||
-I$(DEPTH)/Compiler/Optimizer \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator/md \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator/md/$(CPU_ARCH) \
|
||||
-I$(DEPTH)/Compiler/RegisterAllocator \
|
||||
-I$(DEPTH)/Driver/StandAloneJava \
|
||||
-I$(DEPTH)/Debugger \
|
||||
$(NULL)
|
||||
|
||||
CXXSRCS = \
|
||||
RegisterAllocator.cpp \
|
||||
RegisterAllocatorTools.cpp \
|
||||
DominatorGraph.cpp \
|
||||
VirtualRegister.cpp \
|
||||
BitSet.cpp \
|
||||
SparseSet.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
libs:: $(MODULE)
|
||||
392
mozilla/ef/Compiler/RegisterAllocator/PhiNodeRemover.h
Normal file
392
mozilla/ef/Compiler/RegisterAllocator/PhiNodeRemover.h
Normal file
@@ -0,0 +1,392 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _PHI_NODE_REMOVER_H_
|
||||
#define _PHI_NODE_REMOVER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "DominatorGraph.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "Liveness.h"
|
||||
#include "Instruction.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "SparseSet.h"
|
||||
#include <string.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterNameNode -
|
||||
|
||||
struct RegisterNameNode
|
||||
{
|
||||
RegisterNameNode* next;
|
||||
RegisterName newName;
|
||||
Uint32 nextPushed;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CopyData -
|
||||
|
||||
struct CopyData
|
||||
{
|
||||
RegisterName source;
|
||||
RegisterClassKind classKind;
|
||||
Uint32 useCount;
|
||||
bool isLiveOut;
|
||||
RegisterName sourceNameToUse;
|
||||
RegisterName temporaryName;
|
||||
RegisterNameNode* newName;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// PhiNodeRemover<RegisterPressure> -
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct PhiNodeRemover
|
||||
{
|
||||
// Replace the phi nodes by copy instructions.
|
||||
static void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
};
|
||||
|
||||
// Split some of the critical edges and return true if there are still some
|
||||
// in the graph after that.
|
||||
//
|
||||
static bool splitCriticalEdges(ControlGraph& /*cg*/)
|
||||
{
|
||||
// FIX: not implemented.
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void pushName(Pool& pool, RegisterNameNode** stack, SparseSet& pushed, Uint32* nodeListPointer, RegisterName oldName, RegisterName newName)
|
||||
{
|
||||
RegisterNameNode& newNode = *new(pool) RegisterNameNode();
|
||||
|
||||
if (pushed.test(oldName))
|
||||
(*stack)->newName = newName;
|
||||
else {
|
||||
newNode.newName = newName;
|
||||
newNode.nextPushed = *nodeListPointer;
|
||||
*nodeListPointer = oldName;
|
||||
newNode.next = *stack;
|
||||
*stack = &newNode;
|
||||
pushed.set(oldName);
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void PhiNodeRemover<RegisterPressure>::replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Initialize the local variables.
|
||||
//
|
||||
|
||||
// When we insert the copies we will also need to create new VirtualRegisters for
|
||||
// the insertion of temporaries. The maximum number of temporary register will not
|
||||
// exceed the number of phiNodes in the primitive graph.
|
||||
Uint32 nameCount = vrManager.getSize();
|
||||
Uint32 maxNameCount = nameCount;
|
||||
for (Uint32 n = 0; n < nNodes; n++)
|
||||
maxNameCount += nodes[n]->getPhiNodes().length();
|
||||
|
||||
// If the CFG contains some critical edges (backward edge which source has more than one
|
||||
// outgoing edge and destination has more than one incomimg edge) then we need the liveness
|
||||
// information to be able to insert temporary copies.
|
||||
RegisterPressure::Set* liveOut = NULL;
|
||||
if (splitCriticalEdges(controlGraph))
|
||||
liveOut = Liveness<LowRegisterPressure>::analysis(controlGraph, nameCount).liveOut;
|
||||
|
||||
DominatorGraph dGraph(controlGraph);
|
||||
|
||||
SparseSet pushed(pool, maxNameCount);
|
||||
SparseSet destinationList(pool, maxNameCount);
|
||||
SparseSet workList(pool, maxNameCount);
|
||||
|
||||
CopyData* copyStats = new(pool) CopyData[maxNameCount];
|
||||
memset(copyStats, '\0', maxNameCount*sizeof(CopyData));
|
||||
|
||||
struct NodeStack {
|
||||
Uint32* next;
|
||||
Uint32* limit;
|
||||
Uint32 pushedList;
|
||||
};
|
||||
|
||||
// Allocate the node stack and initialize the node stack pointer.
|
||||
NodeStack* nodeStack = new(pool) NodeStack[nNodes + 1];
|
||||
NodeStack* nodeStackPtr = nodeStack;
|
||||
|
||||
// We start by the begin node.
|
||||
Uint32 startNode = 0;
|
||||
Uint32* next = &startNode;
|
||||
Uint32* limit = &startNode + 1;
|
||||
|
||||
while (true) {
|
||||
|
||||
if (next == limit) {
|
||||
// If there are no more node in the sibling, we have to pop the current
|
||||
// frame from the stack and update the copyStats of the pushed nodes.
|
||||
//
|
||||
if (nodeStackPtr == nodeStack)
|
||||
// We are at the bottom of the stack and there are no more nodes
|
||||
// to look at. We are done !
|
||||
break;
|
||||
|
||||
--nodeStackPtr;
|
||||
// We are done with all the children of this node in the dominator tree.
|
||||
// We need to update the copy information of all the new names pushed
|
||||
// during the walk over this node.
|
||||
Uint32 pushedList = nodeStackPtr->pushedList;
|
||||
while (pushedList != 0) {
|
||||
Uint32 nextName = copyStats[pushedList].newName->nextPushed;
|
||||
copyStats[pushedList].newName = copyStats[pushedList].newName->next;
|
||||
pushedList = nextName;
|
||||
}
|
||||
|
||||
// restore the previous frame.
|
||||
next = nodeStackPtr->next;
|
||||
limit = nodeStackPtr->limit;
|
||||
} else {
|
||||
Uint32 currentNode = *next++;
|
||||
Uint32 pushedList = 0;
|
||||
|
||||
|
||||
// Initialize the sets.
|
||||
pushed.clear();
|
||||
destinationList.clear();
|
||||
|
||||
// STEP1:
|
||||
// Walk the instruction list and to replace all the instruction uses with their new name.
|
||||
// If the instruction is a phi node and its defined register is alive at the end of this
|
||||
// block then we push the defined register into the stack.
|
||||
//
|
||||
ControlNode& node = *nodes[currentNode];
|
||||
RegisterPressure::Set* currentLiveOut = (liveOut != NULL) ? &liveOut[currentNode] : (RegisterPressure::Set*) 0;
|
||||
|
||||
InstructionList& phiNodes = node.getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
|
||||
assert(usePtr->isRegister());
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
|
||||
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
|
||||
usePtr->setRegisterName(copyStats[name].newName->newName);
|
||||
}
|
||||
|
||||
if (currentLiveOut != NULL) {
|
||||
// This is a phi node and we have to push its defined name if it is live
|
||||
// at the end of the node. We only need to do this if the CFG has critical edges.
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
RegisterName name = phiNode.getInstructionDefineBegin()[0].getRegisterName();
|
||||
|
||||
if (currentLiveOut->test(name))
|
||||
pushName(pool, &(copyStats[name].newName), pushed, &pushedList, name, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
|
||||
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
|
||||
usePtr->setRegisterName(copyStats[name].newName->newName);
|
||||
}
|
||||
}
|
||||
|
||||
// STEP2:
|
||||
// Look at this node's successors' phiNodes. We keep track of the number of time
|
||||
// a VR will be used by another copy instruction and insert each definition into the
|
||||
// destinationList. This is the only pass over this node's successors as we will
|
||||
// get all the information we need in the CopyData structures.
|
||||
//
|
||||
ControlEdge* successorEdgeEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorEdgePtr = node.getSuccessorsBegin(); successorEdgePtr < successorEdgeEnd; successorEdgePtr++) {
|
||||
Uint32 useIndex = successorEdgePtr->getIndex();
|
||||
ControlNode& successor = successorEdgePtr->getTarget();
|
||||
|
||||
// Look at its phi nodes. The phi nodes are at the top of the instruction list. We exit
|
||||
// as soon as we find an instruction which is not a phi node
|
||||
InstructionList& phiNodes = successor.getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
assert((phiNode.getInstructionUseBegin() + useIndex) < phiNode.getInstructionUseEnd());
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd());
|
||||
|
||||
InstructionUse& source = phiNode.getInstructionUseBegin()[useIndex];
|
||||
InstructionDefine& destination = phiNode.getInstructionDefineBegin()[0];
|
||||
|
||||
assert(source.isRegister() && destination.isRegister());
|
||||
|
||||
RegisterName sourceName = source.getRegisterName();
|
||||
RegisterName destinationName = destination.getRegisterName();
|
||||
|
||||
// Get the correct name for the source.
|
||||
if (copyStats[sourceName].newName != NULL)
|
||||
sourceName = copyStats[sourceName].newName->newName;
|
||||
|
||||
// Update the CopyData structures.
|
||||
if ((sourceName != rnInvalid) && (sourceName != destinationName)) {
|
||||
copyStats[destinationName].source = sourceName;
|
||||
copyStats[destinationName].classKind = destination.getRegisterClass();
|
||||
copyStats[destinationName].isLiveOut = (currentLiveOut != NULL) ? currentLiveOut->test(destinationName) : false;
|
||||
copyStats[destinationName].sourceNameToUse = destinationName;
|
||||
copyStats[sourceName].sourceNameToUse = sourceName;
|
||||
copyStats[sourceName].useCount++;
|
||||
destinationList.set(destinationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP3:
|
||||
// Insert into the worklist only the destination registers that will be not used in
|
||||
// another copy instruction in this block.
|
||||
//
|
||||
assert(workList.getSize() == 0);
|
||||
for (SparseSet::iterator d = destinationList.begin(); !destinationList.done(d); d = destinationList.advance(d)) {
|
||||
Uint32 dest = destinationList.get(d);
|
||||
if (copyStats[dest].useCount == 0)
|
||||
workList.set(dest);
|
||||
}
|
||||
|
||||
// STEP4:
|
||||
// Insert the copy instructions.
|
||||
//
|
||||
Uint32 destinationListSize = destinationList.getSize();
|
||||
InstructionList::iterator endOfTheNode = instructions.end();
|
||||
|
||||
// Find the right place to insert the copy instructions.
|
||||
if (destinationListSize != 0)
|
||||
while (instructions.get(endOfTheNode).getFlags() & ifControl)
|
||||
endOfTheNode = instructions.retreat(endOfTheNode);
|
||||
|
||||
while (destinationListSize != 0) {
|
||||
while(workList.getSize()) {
|
||||
RegisterName destinationName = RegisterName(workList.getOne());
|
||||
RegisterName sourceName = copyStats[destinationName].source;
|
||||
|
||||
workList.clear(destinationName);
|
||||
if (copyStats[destinationName].isLiveOut && !copyStats[destinationName].temporaryName) {
|
||||
// Lost copy problem.
|
||||
copyStats[destinationName].isLiveOut = false;
|
||||
|
||||
RegisterName sourceName = destinationName;
|
||||
RegisterClassKind classKind = copyStats[sourceName].classKind;
|
||||
RegisterName destinationName = getName(vrManager.newVirtualRegister(classKind));
|
||||
assert(destinationName < maxNameCount);
|
||||
|
||||
copyStats[destinationName].classKind = classKind;
|
||||
copyStats[sourceName].useCount = 0;
|
||||
|
||||
// We need to insert a copy to a temporary register to keep the
|
||||
// source register valid at the end of the node defining it.
|
||||
// This copy will be inserted right after the phi node defining it.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
Instruction* definingPhiNode = vrManager.getVirtualRegister(from).getDefiningInstruction();
|
||||
assert(definingPhiNode && (definingPhiNode->getFlags() & ifPhiNode) != 0);
|
||||
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*definingPhiNode->getPrimitive(), fromID, toID);
|
||||
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
|
||||
definingPhiNode->getPrimitive()->getContainer()->getInstructions().addFirst(copy);
|
||||
|
||||
copyStats[sourceName].temporaryName = destinationName;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
}
|
||||
|
||||
// Insert the copy instruction at the end of the current node.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
|
||||
RegisterClassKind classKind = copyStats[destinationName].classKind;
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
|
||||
instructions.insertAfter(copy, endOfTheNode);
|
||||
endOfTheNode = instructions.advance(endOfTheNode);
|
||||
|
||||
copyStats[sourceName].useCount = 0;
|
||||
if (destinationList.test(sourceName) && copyStats[sourceName].isLiveOut)
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
copyStats[sourceName].isLiveOut = false;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
|
||||
if (destinationList.test(sourceName))
|
||||
workList.set(sourceName);
|
||||
destinationList.clear(destinationName);
|
||||
}
|
||||
|
||||
destinationListSize = destinationList.getSize();
|
||||
if (destinationListSize != 0) {
|
||||
RegisterName sourceName = RegisterName(destinationList.getOne());
|
||||
RegisterName destinationName;
|
||||
|
||||
if (!copyStats[sourceName].temporaryName) {
|
||||
// Cycle problem.
|
||||
RegisterClassKind classKind = copyStats[sourceName].classKind;
|
||||
destinationName = getName(vrManager.newVirtualRegister(classKind));
|
||||
assert(destinationName < maxNameCount);
|
||||
|
||||
copyStats[destinationName].classKind = classKind;
|
||||
copyStats[sourceName].temporaryName = destinationName;
|
||||
|
||||
// Insert the copy instruction at the end of the current node.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
|
||||
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
|
||||
instructions.insertAfter(copy, endOfTheNode);
|
||||
endOfTheNode = instructions.advance(endOfTheNode);
|
||||
} else
|
||||
destinationName = copyStats[sourceName].temporaryName;
|
||||
|
||||
copyStats[sourceName].useCount = 0;
|
||||
copyStats[sourceName].isLiveOut = false;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
|
||||
workList.set(sourceName);
|
||||
}
|
||||
}
|
||||
|
||||
nodeStackPtr->pushedList = pushedList;
|
||||
nodeStackPtr->next = next;
|
||||
nodeStackPtr->limit = limit;
|
||||
++nodeStackPtr;
|
||||
next = dGraph.getSuccessorsBegin(currentNode);
|
||||
limit = dGraph.getSuccessorsEnd(currentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _PHI_NODE_REMOVER_H_
|
||||
155
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.cpp
Normal file
155
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "PhiNodeRemover.h"
|
||||
#include "LiveRange.h"
|
||||
#include "Liveness.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "LiveRangeGraph.h"
|
||||
#include "Coalescing.h"
|
||||
#include "Spilling.h"
|
||||
#include "Coloring.h"
|
||||
#include "Splits.h"
|
||||
|
||||
class Pool;
|
||||
class ControlGraph;
|
||||
class VirtualRegisterManager;
|
||||
class InstructionEmitter;
|
||||
|
||||
UT_DEFINE_LOG_MODULE(RegAlloc);
|
||||
|
||||
void RegisterAllocator::allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
{
|
||||
// Insert the phi node instructions. We want to do this to have a single defined register per instruction.
|
||||
// If we keep the PhiNode (as a DataNode) and a PhiNode is of DoubleWordKind then we have to execute
|
||||
// some special code for the high word annotation.
|
||||
//
|
||||
RegisterAllocatorTools::insertPhiNodeInstructions(controlGraph, emitter);
|
||||
|
||||
// Perform some tests on the instruction graph.
|
||||
//
|
||||
DEBUG_ONLY(RegisterAllocatorTools::testTheInstructionGraph(controlGraph, vrManager));
|
||||
|
||||
// Replace the phi node instructions by their equivalent copy instructions.
|
||||
//
|
||||
PhiNodeRemover<LowRegisterPressure>::replacePhiNodes(controlGraph, vrManager, emitter);
|
||||
|
||||
// Do the register allocation.
|
||||
//
|
||||
RegisterAllocator registerAllocator(pool, controlGraph, vrManager, emitter);
|
||||
registerAllocator.doGraphColoring();
|
||||
}
|
||||
|
||||
void RegisterAllocator::doGraphColoring()
|
||||
{
|
||||
// Initialize the liverange map.
|
||||
//
|
||||
initLiveRanges();
|
||||
|
||||
// Build the live ranges. We do this to compress the number of RegisterNames
|
||||
// used in the insterference graph.
|
||||
//
|
||||
LiveRange<LowRegisterPressure>::build(*this);
|
||||
|
||||
// Remove unnecessary copies.
|
||||
//
|
||||
RegisterAllocatorTools::removeUnnecessaryCopies(*this);
|
||||
|
||||
for (Uint8 loop = 0; loop < 10; loop++) {
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********* RegisterAllocator loop %d *********\n", loop));
|
||||
|
||||
while(true) {
|
||||
// Build the interference graph.
|
||||
//
|
||||
iGraph.build();
|
||||
|
||||
// Coalesce the copy instructions.
|
||||
//
|
||||
if (!Coalescing<LowRegisterPressure>::coalesce(*this))
|
||||
break;
|
||||
}
|
||||
|
||||
// Print the interference graph.
|
||||
//
|
||||
DEBUG_LOG_ONLY(iGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
|
||||
|
||||
// Calculate the spill costs.
|
||||
//
|
||||
Spilling<LowRegisterPressure>::calculateSpillCosts(*this);
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSpillCosts(*this));
|
||||
|
||||
// Calculate the split costs.
|
||||
//
|
||||
Splits<LowRegisterPressure>::calculateSplitCosts(*this);
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSplitCosts(*this));
|
||||
|
||||
// Build the live range graph.
|
||||
//
|
||||
lGraph.build();
|
||||
DEBUG_LOG_ONLY(lGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
|
||||
|
||||
// Color the graph. If it succeeds then we're done with the
|
||||
// register allocation.
|
||||
//
|
||||
if (Coloring<LowRegisterPressure>::color(*this)) {
|
||||
// Write the final colors in the instruction graph.
|
||||
//
|
||||
Coloring<LowRegisterPressure>::finalColoring(*this);
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********** RegisterAllocator done **********\n"));
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printInstructions(*this));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to spill some registers.
|
||||
//
|
||||
Spilling<LowRegisterPressure>::insertSpillCode(*this);
|
||||
|
||||
// Insert the split instructions.
|
||||
//
|
||||
Splits<LowRegisterPressure>::insertSplitCode(*this);
|
||||
|
||||
// Update the live ranges.
|
||||
//
|
||||
// FIX
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
RegisterAllocatorTools::updateInstructionGraph(*this);
|
||||
RegisterAllocatorTools::printInstructions(*this);
|
||||
#endif
|
||||
fprintf(stderr, "!!! Coloring failed after 10 loops !!!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
void RegisterAllocator::initLiveRanges()
|
||||
{
|
||||
Uint32 count = this->nameCount;
|
||||
RegisterName* name2range = new(pool) RegisterName[nameCount];
|
||||
for (RegisterName r = RegisterName(1); r < count; r = RegisterName(r + 1))
|
||||
name2range[r] = r;
|
||||
this->name2range = name2range;
|
||||
rangeCount = count;
|
||||
}
|
||||
88
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.h
Normal file
88
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_ALLOCATOR_H_
|
||||
#define _REGISTER_ALLOCATOR_H_
|
||||
|
||||
class Pool;
|
||||
class ControlGraph;
|
||||
class InstructionEmitter;
|
||||
struct SpillCost;
|
||||
struct SplitCost;
|
||||
|
||||
#include "Liveness.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h" // This should included by Backend.cpp
|
||||
#include "InterferenceGraph.h"
|
||||
#include "LiveRangeGraph.h"
|
||||
|
||||
//template <class RegisterPressure>
|
||||
class RegisterAllocator
|
||||
{
|
||||
public:
|
||||
|
||||
Pool& pool; //
|
||||
ControlGraph& controlGraph; //
|
||||
VirtualRegisterManager& vrManager; //
|
||||
InstructionEmitter& emitter; //
|
||||
|
||||
RegisterName* name2range; //
|
||||
RegisterName* color; //
|
||||
SpillCost* spillCost; //
|
||||
SparseSet* willSpill; //
|
||||
SplitCost* splitCost; //
|
||||
NameLinkedList** splitAround; //
|
||||
InterferenceGraph<LowRegisterPressure> iGraph; //
|
||||
LiveRangeGraph<LowRegisterPressure> lGraph; //
|
||||
LivenessInfo<LowRegisterPressure> liveness; //
|
||||
Uint32 nameCount; //
|
||||
Uint32 rangeCount; //
|
||||
bool splitFound; //
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
//
|
||||
void doGraphColoring();
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
//
|
||||
inline RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
|
||||
//
|
||||
//
|
||||
bool canInterfere(RegisterName /*name1*/, RegisterName /*name2*/) const {return true;}
|
||||
|
||||
//
|
||||
//
|
||||
void initLiveRanges();
|
||||
|
||||
//
|
||||
//
|
||||
static void allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
inline RegisterAllocator::RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
: pool(pool), controlGraph(controlGraph), vrManager(vrManager), emitter(emitter), iGraph(*this), lGraph(*this), nameCount(vrManager.getSize()) {}
|
||||
|
||||
#endif // _REGISTER_ALLOCATOR_H_
|
||||
|
||||
355
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.cpp
Normal file
355
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.cpp
Normal file
@@ -0,0 +1,355 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Primitives.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "Spilling.h"
|
||||
#include "Splits.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
#ifdef DEBUG
|
||||
void RegisterAllocatorTools::testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
|
||||
{
|
||||
// Test the declared VirtualRegisters. The register allocator tries to condense the register universe.
|
||||
// Any gap in the VirtualRegister names will be a loss of efficiency !!!!
|
||||
|
||||
Uint32 nameCount = vrManager.getSize();
|
||||
BitSet registerSeen(controlGraph.pool, nameCount);
|
||||
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
registerSeen.set(usePtr->getRegisterName());
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
registerSeen.set(definePtr->getRegisterName());
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
registerSeen.set(usePtr->getRegisterName());
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
registerSeen.set(definePtr->getRegisterName());
|
||||
}
|
||||
}
|
||||
|
||||
bool renameRegisters = false;
|
||||
for (BitSet::iterator i = registerSeen.nextZero(0); !registerSeen.done(i); i = registerSeen.nextZero(i)) {
|
||||
renameRegisters = true;
|
||||
fprintf(stderr,
|
||||
"WARNING: The VirtualRegister vr%d has been allocated during CodeGeneration but\n"
|
||||
" is never used nor defined by any instruction in the instruction graph\n"
|
||||
" PLEASE FIX \n",
|
||||
i);
|
||||
}
|
||||
if (renameRegisters) {
|
||||
Instruction** definingInstruction = new Instruction*[nameCount];
|
||||
memset(definingInstruction, '\0', nameCount * sizeof(Instruction*));
|
||||
RegisterName* newName = new RegisterName[nameCount];
|
||||
memset(newName, '\0', nameCount * sizeof(RegisterName));
|
||||
RegisterName nextName = RegisterName(1);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
usePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName name = definePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
definePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
usePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName name = definePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
definePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vrManager.setSize(nextName);
|
||||
|
||||
for (RegisterName r = RegisterName(1); r < nextName; r = RegisterName(r + 1))
|
||||
vrManager.getVirtualRegister(r).definingInstruction = definingInstruction[r];
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("RegisterMap:\n"));
|
||||
for (Uint32 i = 1; i < nameCount; i++)
|
||||
if (newName[i] != 0)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d becomes vr%d.\n", i, newName[i]));
|
||||
else
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d is dead.\n", i));
|
||||
|
||||
|
||||
delete newName;
|
||||
delete definingInstruction;
|
||||
}
|
||||
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
void RegisterAllocatorTools::removeUnnecessaryCopies(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i);) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
i = instructions.advance(i);
|
||||
|
||||
if (instruction.getFlags() & ifCopy) {
|
||||
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
|
||||
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
|
||||
|
||||
RegisterName source = name2range[instruction.getInstructionUseBegin()[0].getRegisterName()];
|
||||
RegisterName destination = name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()];
|
||||
|
||||
if (source == destination)
|
||||
instruction.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegisterAllocatorTools::updateInstructionGraph(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegisterAllocatorTools::insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
DoublyLinkedList<PhiNode>& phiNodes = node.getPhiNodes();
|
||||
|
||||
if (!phiNodes.empty()) {
|
||||
|
||||
// Set the index of the incoming edges.
|
||||
Uint32 index = 0;
|
||||
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
|
||||
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p))
|
||||
predecessors.get(p).setIndex(index++);
|
||||
|
||||
// Insert the phi node instruction in the instruction list.
|
||||
for (DoublyLinkedList<PhiNode>::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
PhiNode& phiNode = phiNodes.get(i);
|
||||
ValueKind kind = phiNode.getKind();
|
||||
|
||||
if (!isStorableKind(kind))
|
||||
continue;
|
||||
|
||||
RegisterClassKind classKind = rckGeneral; // FIX: get class kind from phi node kind.
|
||||
Uint32 nInputs = phiNode.nInputs();
|
||||
|
||||
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
|
||||
|
||||
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drLow);
|
||||
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
|
||||
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drLow);
|
||||
|
||||
node.addPhiNodeInstruction(phiNodeInstruction);
|
||||
|
||||
if (isDoublewordKind(kind)) {
|
||||
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
|
||||
|
||||
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drHigh);
|
||||
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
|
||||
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drHigh);
|
||||
|
||||
node.addPhiNodeInstruction(phiNodeInstruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
|
||||
void RegisterAllocatorTools::printSpillCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
SpillCost* cost = registerAllocator.spillCost;
|
||||
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Spill costs:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : ", i));
|
||||
if (cost[i].infinite)
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("infinite\n"));
|
||||
else
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%f\n", cost[i].cost));
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAllocatorTools::printSplitCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
SplitCost* cost = registerAllocator.splitCost;
|
||||
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Split costs:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : loads = %f stores = %f\n", i, cost[i].loads, cost[i].stores));
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAllocatorTools::printInstructions(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
ControlNode** nodes = registerAllocator.controlGraph.dfsList;
|
||||
Uint32 nNodes = registerAllocator.controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d:\n", n));
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
if (!phiNodes.empty()) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" PhiNodes:\n", n));
|
||||
for(InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
phiNodes.get(i).printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
if (!instructions.empty())
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" Instructions:\n", n));
|
||||
}
|
||||
|
||||
for(InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
instructions.get(i).printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
117
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.h
Normal file
117
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.h
Normal file
@@ -0,0 +1,117 @@
|
||||
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
|
||||
//
|
||||
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
// NETSCAPE COMMUNICATIONS CORPORATION
|
||||
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
|
||||
// Reserved. Use of this Source Code is subject to the terms of the
|
||||
// applicable license agreement from Netscape Communications Corporation.
|
||||
// The copyright notice(s) in this Source Code does not indicate actual or
|
||||
// intended publication of this Source Code.
|
||||
//
|
||||
// $Id: RegisterAllocatorTools.h,v 1.1.2.1 1999-03-02 16:12:05 fur%netscape.com Exp $
|
||||
//
|
||||
|
||||
#ifndef _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
#define _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
|
||||
#include "LogModule.h"
|
||||
#include "RegisterTypes.h"
|
||||
#include <string.h>
|
||||
|
||||
class RegisterAllocator;
|
||||
class ControlGraph;
|
||||
class InstructionEmitter;
|
||||
class VirtualRegisterManager;
|
||||
|
||||
struct RegisterAllocatorTools
|
||||
{
|
||||
//
|
||||
//
|
||||
static void insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter);
|
||||
|
||||
//
|
||||
//
|
||||
static void updateInstructionGraph(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void removeUnnecessaryCopies(RegisterAllocator& registerAllocator);
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
//
|
||||
static void testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
|
||||
#endif // DEBUG
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
//
|
||||
//
|
||||
static void printInstructions(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void printSpillCosts(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void printSplitCosts(RegisterAllocator& registerAllocator);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
//
|
||||
// FIX: this should go in a class (LookupTable ?)
|
||||
//
|
||||
|
||||
inline RegisterName findRoot(RegisterName name, RegisterName* table)
|
||||
{
|
||||
RegisterName* stack = table;
|
||||
RegisterName* stackPtr = stack;
|
||||
|
||||
RegisterName newName;
|
||||
while((newName = table[name]) != name) {
|
||||
*--stackPtr = name;
|
||||
name = newName;
|
||||
}
|
||||
|
||||
while (stackPtr != stack)
|
||||
table[*stackPtr++] = name;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
inline void init(RegisterName* table, Uint32 nameCount)
|
||||
{
|
||||
for (RegisterName r = RegisterName(0); r < nameCount; r = RegisterName(r + 1))
|
||||
table[r] = r;
|
||||
}
|
||||
|
||||
inline Uint32 compress(RegisterName* name2range, RegisterName* table, Uint32 nameCount, Uint32 tableSize)
|
||||
{
|
||||
RegisterName* liveRange = new RegisterName[tableSize];
|
||||
memset(liveRange, '\0', tableSize * sizeof(RegisterName));
|
||||
|
||||
// Update the lookup table.
|
||||
for (RegisterName r = RegisterName(1); r < tableSize; r = RegisterName(r + 1))
|
||||
findRoot(r, table);
|
||||
|
||||
// Count the liveranges.
|
||||
Uint32 liveRangeCount = 1;
|
||||
for (RegisterName s = RegisterName(1); s < tableSize; s = RegisterName(s + 1))
|
||||
if (table[s] == s)
|
||||
liveRange[s] = RegisterName(liveRangeCount++);
|
||||
|
||||
for (RegisterName t = RegisterName(1); t < nameCount; t = RegisterName(t + 1))
|
||||
name2range[t] = liveRange[table[name2range[t]]];
|
||||
|
||||
return liveRangeCount;
|
||||
}
|
||||
|
||||
inline double doLog10(Uint32 power)
|
||||
{
|
||||
double log = 1.0;
|
||||
while (power--)
|
||||
log *= 10.0;
|
||||
return log;
|
||||
}
|
||||
|
||||
#endif // _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
38
mozilla/ef/Compiler/RegisterAllocator/RegisterAssigner.h
Normal file
38
mozilla/ef/Compiler/RegisterAllocator/RegisterAssigner.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_ASSIGNER_H_
|
||||
#define _REGISTER_ASSIGNER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "VirtualRegister.h"
|
||||
|
||||
class FastBitMatrix;
|
||||
|
||||
class RegisterAssigner
|
||||
{
|
||||
protected:
|
||||
VirtualRegisterManager& vRegManager;
|
||||
|
||||
public:
|
||||
RegisterAssigner(VirtualRegisterManager& vrMan) : vRegManager(vrMan) {}
|
||||
|
||||
virtual bool assignRegisters(FastBitMatrix& interferenceMatrix) = 0;
|
||||
};
|
||||
|
||||
#endif /* _REGISTER_ASSIGNER_H_ */
|
||||
25
mozilla/ef/Compiler/RegisterAllocator/RegisterClass.h
Normal file
25
mozilla/ef/Compiler/RegisterAllocator/RegisterClass.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_CLASS_H_
|
||||
#define _REGISTER_CLASS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
#endif // _REGISTER_CLASS_H_
|
||||
37
mozilla/ef/Compiler/RegisterAllocator/RegisterPressure.h
Normal file
37
mozilla/ef/Compiler/RegisterAllocator/RegisterPressure.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_PRESSURE_H_
|
||||
#define _REGISTER_PRESSURE_H_
|
||||
|
||||
#include "BitSet.h"
|
||||
#include "HashSet.h"
|
||||
|
||||
struct LowRegisterPressure
|
||||
{
|
||||
typedef BitSet Set;
|
||||
static const bool setIsOrdered = true;
|
||||
};
|
||||
|
||||
struct HighRegisterPressure
|
||||
{
|
||||
typedef HashSet Set;
|
||||
static const bool setIsOrdered = false;
|
||||
};
|
||||
|
||||
#endif // _REGISTER_PRESSURE_H_
|
||||
104
mozilla/ef/Compiler/RegisterAllocator/RegisterTypes.h
Normal file
104
mozilla/ef/Compiler/RegisterAllocator/RegisterTypes.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_TYPES_H_
|
||||
#define _REGISTER_TYPES_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterName -
|
||||
//
|
||||
|
||||
enum RegisterName {
|
||||
rnInvalid = 0,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterClassKind -
|
||||
//
|
||||
|
||||
enum RegisterClassKind {
|
||||
rckInvalid = 0,
|
||||
rckGeneral,
|
||||
rckStackSlot,
|
||||
|
||||
nRegisterClassKind
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterID -
|
||||
//
|
||||
|
||||
enum RegisterID {
|
||||
invalidID = 0
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterKind -
|
||||
//
|
||||
|
||||
enum RegisterKind {
|
||||
rkCallerSave = 0,
|
||||
rkCalleeSave,
|
||||
};
|
||||
|
||||
struct NameLinkedList {
|
||||
RegisterName name;
|
||||
NameLinkedList* next;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
const registerNameMask = 0x03ffffff;
|
||||
const coloredRegisterMask = 0x04000000;
|
||||
const machineRegisterMask = 0x08000000;
|
||||
const registerClassMask = 0xf0000000;
|
||||
|
||||
const registerNameShift = 0;
|
||||
const coloredRegisterShift = 26;
|
||||
const machineRegisterShift = 27;
|
||||
const registerClassShift = 28;
|
||||
|
||||
#else // DEBUG
|
||||
|
||||
const registerNameMask = 0x0fffffff;
|
||||
const registerClassMask = 0xf0000000;
|
||||
|
||||
const registerNameShift = 0;
|
||||
const registerClassShift = 28;
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
inline RegisterClassKind getClass(RegisterID registerID) {return RegisterClassKind((registerID & registerClassMask) >> registerClassShift);}
|
||||
inline RegisterName getName(RegisterID registerID) {return RegisterName((registerID & registerNameMask) >> registerNameShift);}
|
||||
inline void setClass(RegisterID& registerID, RegisterClassKind classKind) {registerID = RegisterID((registerID & ~registerClassMask) | ((classKind << registerClassShift) & registerClassMask));}
|
||||
inline void setName(RegisterID& registerID, RegisterName name) {assert((name & ~registerNameMask) == 0); registerID = RegisterID((registerID & ~registerNameMask) | ((name << registerNameShift) & registerNameMask));}
|
||||
inline RegisterID buildRegisterID(RegisterName name, RegisterClassKind classKind) {return RegisterID(((classKind << registerClassShift) & registerClassMask) | ((name << registerNameShift) & registerNameMask));}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
inline bool isMachineRegister(RegisterID rid) {return (rid & machineRegisterMask) != 0;}
|
||||
inline void setMachineRegister(RegisterID& rid) {rid = RegisterID(rid | machineRegisterMask);}
|
||||
inline bool isColoredRegister(RegisterID rid) {return (rid & coloredRegisterMask) != 0;}
|
||||
inline void setColoredRegister(RegisterID& rid) {rid = RegisterID(rid | coloredRegisterMask);}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
#endif // _REGISTER_TYPES_H_
|
||||
32
mozilla/ef/Compiler/RegisterAllocator/SSATools.cpp
Normal file
32
mozilla/ef/Compiler/RegisterAllocator/SSATools.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "SSATools.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "Liveness.h"
|
||||
|
||||
void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
|
||||
{
|
||||
if (!controlGraph.hasBackEdges)
|
||||
return;
|
||||
|
||||
Liveness liveness(controlGraph.pool);
|
||||
liveness.buildLivenessAnalysis(controlGraph, vrManager);
|
||||
}
|
||||
29
mozilla/ef/Compiler/RegisterAllocator/SSATools.h
Normal file
29
mozilla/ef/Compiler/RegisterAllocator/SSATools.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SSA_TOOLS_H_
|
||||
#define _SSA_TOOLS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
|
||||
class ControlGraph;
|
||||
class VirtualRegisterManager;
|
||||
|
||||
extern void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
|
||||
|
||||
#endif // _SSA_TOOLS_H_
|
||||
37
mozilla/ef/Compiler/RegisterAllocator/SparseSet.cpp
Normal file
37
mozilla/ef/Compiler/RegisterAllocator/SparseSet.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "SparseSet.h"
|
||||
#include "BitSet.h"
|
||||
#include "Pool.h"
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
//
|
||||
void SparseSet::printPretty(LogModuleObject log)
|
||||
{
|
||||
Pool pool;
|
||||
BitSet set(pool, universeSize);
|
||||
|
||||
for (Uint32 i = 0; i < count; i++)
|
||||
set.set(node[i].element);
|
||||
|
||||
set.printPretty(log);
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
168
mozilla/ef/Compiler/RegisterAllocator/SparseSet.h
Normal file
168
mozilla/ef/Compiler/RegisterAllocator/SparseSet.h
Normal file
@@ -0,0 +1,168 @@
|
||||
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
|
||||
//
|
||||
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
// NETSCAPE COMMUNICATIONS CORPORATION
|
||||
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
|
||||
// Reserved. Use of this Source Code is subject to the terms of the
|
||||
// applicable license agreement from Netscape Communications Corporation.
|
||||
// The copyright notice(s) in this Source Code does not indicate actual or
|
||||
// intended publication of this Source Code.
|
||||
//
|
||||
// $Id: SparseSet.h,v 1.1.2.1 1999-03-02 16:12:07 fur%netscape.com Exp $
|
||||
//
|
||||
|
||||
#ifndef _SPARSE_SET_H_
|
||||
#define _SPARSE_SET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "LogModule.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
class SparseSet
|
||||
{
|
||||
private:
|
||||
|
||||
struct Node {
|
||||
Uint32 element;
|
||||
Uint32 stackIndex;
|
||||
};
|
||||
|
||||
Node* node;
|
||||
Uint32 count;
|
||||
Uint32 universeSize;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
SparseSet(const SparseSet&);
|
||||
|
||||
// Check if the given set's universe is of the same size than this universe.
|
||||
void checkUniverseCompatibility(const SparseSet& set) const {assert(set.universeSize == universeSize);}
|
||||
// Check if pos is valid for this set's universe.
|
||||
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
|
||||
|
||||
public:
|
||||
|
||||
SparseSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {node = new(pool) Node[universeSize]; clear();}
|
||||
|
||||
// Clear the sparse set.
|
||||
void clear() {count = 0;}
|
||||
// Clear the element at index.
|
||||
inline void clear(Uint32 index);
|
||||
// Set the element at index.
|
||||
inline void set(Uint32 index);
|
||||
// Return true if the element at index is set.
|
||||
inline bool test(Uint32 index) const;
|
||||
// Union with the given sparse set.
|
||||
inline void or(const SparseSet& set);
|
||||
// Intersection with the given sparse set.
|
||||
inline void and(const SparseSet& set);
|
||||
// Difference with the given sparse set.
|
||||
inline void difference(const SparseSet& set);
|
||||
// Copy set.
|
||||
inline SparseSet& operator = (const SparseSet& set);
|
||||
inline SparseSet& operator = (const BitSet& set);
|
||||
// Return true if the sparse sets are identical.
|
||||
friend bool operator == (const SparseSet& set1, const SparseSet& set2);
|
||||
// Return true if the sparse sets are different.
|
||||
friend bool operator != (const SparseSet& set1, const SparseSet& set2);
|
||||
|
||||
// Logical operators.
|
||||
SparseSet& operator |= (const SparseSet& set) {or(set); return *this;}
|
||||
SparseSet& operator &= (const SparseSet& set) {and(set); return *this;}
|
||||
SparseSet& operator -= (const SparseSet& set) {difference(set); return *this;}
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef Int32 iterator;
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const {return count - 1;}
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const {return --pos;}
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos < 0;}
|
||||
// Return the element for the given iterator;
|
||||
Uint32 get(iterator pos) const {return node[pos].element;}
|
||||
// Return one element of this set.
|
||||
Uint32 getOne() const {assert(count > 0); return node[0].element;}
|
||||
// Return the size of this set.
|
||||
Uint32 getSize() const {return count;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
inline void SparseSet::clear(Uint32 element)
|
||||
{
|
||||
checkMember(element);
|
||||
Uint32 count = this->count;
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
|
||||
if ((stackIndex < count) && (node[stackIndex].element == element)) {
|
||||
Uint32 stackTop = node[count - 1].element;
|
||||
|
||||
node[stackIndex].element = stackTop;
|
||||
node[stackTop].stackIndex = stackIndex;
|
||||
this->count = count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline void SparseSet::set(Uint32 element)
|
||||
{
|
||||
checkMember(element);
|
||||
Uint32 count = this->count;
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
|
||||
if ((stackIndex >= count) || (node[stackIndex].element != element)) {
|
||||
node[count].element = element;
|
||||
node[element].stackIndex = count;
|
||||
this->count = count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool SparseSet::test(Uint32 element) const
|
||||
{
|
||||
checkMember(element);
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
return ((stackIndex < count) && (node[stackIndex].element == element));
|
||||
}
|
||||
|
||||
inline SparseSet& SparseSet::operator = (const SparseSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Uint32 sourceCount = set.getSize();
|
||||
Node* node = this->node;
|
||||
|
||||
memcpy(node, set.node, sourceCount * sizeof(Node));
|
||||
|
||||
for (Uint32 i = 0; i < sourceCount; i++) {
|
||||
Uint32 element = node[i].element;
|
||||
node[element].stackIndex = i;
|
||||
}
|
||||
|
||||
count = sourceCount;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline SparseSet& SparseSet::operator = (const BitSet& set)
|
||||
{
|
||||
// FIX: there's room for optimization here.
|
||||
assert(universeSize == set.getSize());
|
||||
|
||||
clear();
|
||||
for (Int32 i = set.firstOne(); i != -1; i = set.nextOne(i))
|
||||
this->set(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _SPARSE_SET_H_
|
||||
270
mozilla/ef/Compiler/RegisterAllocator/Spilling.cpp
Normal file
270
mozilla/ef/Compiler/RegisterAllocator/Spilling.cpp
Normal file
@@ -0,0 +1,270 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NEW_LAURENTM_CODE
|
||||
#define INCLUDE_EMITTER
|
||||
#include "CpuInfo.h"
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "Spilling.h"
|
||||
|
||||
|
||||
void Spilling::
|
||||
insertSpillCode(ControlNode** dfsList, Uint32 nNodes)
|
||||
{
|
||||
PRUint32 nVirtualRegisters = vRegManager.count();
|
||||
FastBitSet currentLive(vRegManager.pool, nVirtualRegisters);
|
||||
FastBitSet usedInThisInstruction(vRegManager.pool, nVirtualRegisters);
|
||||
RegisterFifo grNeedLoad(nVirtualRegisters);
|
||||
RegisterFifo fpNeedLoad(nVirtualRegisters);
|
||||
|
||||
for (PRInt32 n = nNodes - 1; n >= 0; n--)
|
||||
{
|
||||
PR_ASSERT(grNeedLoad.empty() & fpNeedLoad.empty());
|
||||
ControlNode& node = *dfsList[n];
|
||||
|
||||
currentLive = node.liveAtEnd;
|
||||
|
||||
PRUint32 nGeneralAlive = 0;
|
||||
PRUint32 nFloatingPointAlive = 0;
|
||||
|
||||
// Get the number of registers alive at the end of this node.
|
||||
for (PRInt32 j = currentLive.firstOne(); j != -1; j = currentLive.nextOne(j))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(j);
|
||||
if (vReg.spillInfo.willSpill)
|
||||
{
|
||||
currentLive.clear(j);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive++;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(node.dfsNum == 8) printf("\n________Begin Node %d________\n", node.dfsNum);
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i))
|
||||
{
|
||||
Instruction& instruction = instructions.get(i);
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* defPtr;
|
||||
|
||||
// if(node.dfsNum == 8) { printf("\n");
|
||||
// instruction.printPretty(stdout);
|
||||
// printf("\n"); }
|
||||
|
||||
// Handle definitions
|
||||
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
|
||||
if (defPtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = defPtr->getVirtualRegister();
|
||||
currentLive.clear(vReg.getRegisterIndex());
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive--;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for deaths
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = usePtr->getVirtualRegister();
|
||||
if (!currentLive.test(vReg.getRegisterIndex()))
|
||||
// This is the last use of this register.
|
||||
{
|
||||
currentLive.set(vReg.getRegisterIndex());
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive++;
|
||||
while (/*(nGeneralAlive > NUMBER_OF_GREGISTERS) &&*/ !grNeedLoad.empty())
|
||||
{
|
||||
PRUint32 toLoad = grNeedLoad.get();
|
||||
currentLive.clear(toLoad);
|
||||
nGeneralAlive--;
|
||||
|
||||
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
|
||||
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
|
||||
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
|
||||
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
|
||||
nReg.releaseSelf();
|
||||
}
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive++;
|
||||
while (/*(nFloatingPointAlive > NUMBER_OF_FPREGISTERS) &&*/ !fpNeedLoad.empty())
|
||||
{
|
||||
PRUint32 toLoad = fpNeedLoad.get();
|
||||
currentLive.clear(toLoad);
|
||||
nFloatingPointAlive--;
|
||||
|
||||
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
|
||||
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
|
||||
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
|
||||
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
|
||||
nReg.releaseSelf();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle uses
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = usePtr->getVirtualRegister();
|
||||
PRUint32 registerIndex = vReg.getRegisterIndex();
|
||||
|
||||
if (vReg.spillInfo.willSpill) {
|
||||
#if defined(GENERATE_FOR_X86)
|
||||
if (!instruction.switchUseToSpill((usePtr - useBegin), *vReg.equivalentRegister[vrcStackSlot]))
|
||||
#endif
|
||||
{
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
if (!grNeedLoad.test(registerIndex))
|
||||
{
|
||||
grNeedLoad.put(registerIndex);
|
||||
VirtualRegister& alias = vRegManager.newVirtualRegister(vrcInteger);
|
||||
if (vReg.isPreColored())
|
||||
alias.preColorRegister(vReg.getPreColor());
|
||||
/* if (vReg.hasSpecialInterference) {
|
||||
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
|
||||
alias.specialInterference = vReg.specialInterference;
|
||||
alias.hasSpecialInterference = true;
|
||||
} */
|
||||
vReg.setAlias(alias);
|
||||
vReg.retainSelf();
|
||||
}
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
if (!fpNeedLoad.test(registerIndex))
|
||||
{
|
||||
fpNeedLoad.put(registerIndex);
|
||||
VirtualRegister& alias = vRegManager.newVirtualRegister(vReg.getClass());
|
||||
if (vReg.isPreColored())
|
||||
alias.preColorRegister(vReg.getPreColor());
|
||||
/*if (vReg.hasSpecialInterference) {
|
||||
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
|
||||
alias.specialInterference = vReg.specialInterference;
|
||||
alias.hasSpecialInterference = true;
|
||||
} */
|
||||
vReg.setAlias(alias);
|
||||
vReg.retainSelf();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
usePtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
|
||||
usedInThisInstruction.set(registerIndex);
|
||||
vReg.spillInfo.lastUsingInstruction = &instruction;
|
||||
}
|
||||
currentLive.clear(registerIndex);
|
||||
} else { // will not spill
|
||||
currentLive.set(registerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle definitions
|
||||
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
|
||||
if (defPtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = defPtr->getVirtualRegister();
|
||||
|
||||
if (vReg.spillInfo.willSpill)
|
||||
#if defined(GENERATE_FOR_X86)
|
||||
if (!instruction.switchDefineToSpill((defPtr - defBegin), *vReg.equivalentRegister[vrcStackSlot]))
|
||||
#endif
|
||||
{
|
||||
if (usedInThisInstruction.test(vReg.getRegisterIndex()))
|
||||
// this virtualRegister was used in this instruction and is also defined. We need to move
|
||||
// this virtual register to its alias first and then save it to memory.
|
||||
{
|
||||
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
|
||||
vReg.getAlias(), *vReg.equivalentRegister[vrcStackSlot]);
|
||||
defPtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
|
||||
}
|
||||
else
|
||||
{
|
||||
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
|
||||
vReg, *vReg.equivalentRegister[vrcStackSlot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!grNeedLoad.empty())
|
||||
{
|
||||
PRUint32 nl = grNeedLoad.get();
|
||||
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
|
||||
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
|
||||
|
||||
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
|
||||
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
|
||||
nlReg.releaseSelf();
|
||||
}
|
||||
while (!fpNeedLoad.empty())
|
||||
{
|
||||
PRUint32 nl = fpNeedLoad.get();
|
||||
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
|
||||
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
|
||||
|
||||
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
|
||||
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
|
||||
nlReg.releaseSelf();
|
||||
}
|
||||
|
||||
// if(node.dfsNum == 8) printf("\n________End Node %d________\n", node.dfsNum);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
269
mozilla/ef/Compiler/RegisterAllocator/Spilling.h
Normal file
269
mozilla/ef/Compiler/RegisterAllocator/Spilling.h
Normal file
@@ -0,0 +1,269 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SPILLING_H_
|
||||
#define _SPILLING_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "SparseSet.h"
|
||||
|
||||
template <class RegisterPressure>
|
||||
class Spilling
|
||||
{
|
||||
private:
|
||||
static void insertStoreAfter(Instruction& instruction, RegisterName name);
|
||||
static void insertLoadBefore(Instruction& instruction, RegisterName name);
|
||||
|
||||
public:
|
||||
static void calculateSpillCosts(RegisterAllocator& registerAllocator);
|
||||
static void insertSpillCode(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
struct SpillCost
|
||||
{
|
||||
double loads;
|
||||
double stores;
|
||||
double copies;
|
||||
double cost;
|
||||
bool infinite;
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertSpillCode(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
SparseSet needLoad(pool, rangeCount);
|
||||
SparseSet mustSpill(pool, rangeCount);
|
||||
SparseSet& willSpill = *registerAllocator.willSpill;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
needLoad.clear();
|
||||
currentLive = liveOut[n];
|
||||
mustSpill = currentLive;
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i);) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
i = instructions.retreat(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
bool foundLiveDefine = false;
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
if (currentLive.test(name2range[definePtr->getRegisterName()])) {
|
||||
foundLiveDefine = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
foundLiveDefine = true;
|
||||
break;
|
||||
}
|
||||
if (defineBegin != defineEnd && !foundLiveDefine) {
|
||||
fprintf(stderr, "!!! Removed instruction because it was only defining unused registers !!!\n");
|
||||
instruction.remove();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName range = name2range[definePtr->getRegisterName()];
|
||||
#ifdef DEBUG
|
||||
if (needLoad.test(range))
|
||||
if (!mustSpill.test(range) && registerAllocator.spillCost[range].infinite && willSpill.test(range)) {
|
||||
fprintf(stderr, "Tried to spill a register with infinite spill cost\n");
|
||||
abort();
|
||||
}
|
||||
#endif // DEBUG
|
||||
if (willSpill.test(range))
|
||||
insertStoreAfter(instruction, range);
|
||||
|
||||
needLoad.clear(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy)
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
if (!currentLive.test(range))
|
||||
for (SparseSet::iterator r = needLoad.begin(); !needLoad.done(r); r = needLoad.advance(r)) {
|
||||
RegisterName load = RegisterName(needLoad.get(r));
|
||||
if (willSpill.test(load))
|
||||
insertLoadBefore(instruction, load);
|
||||
mustSpill.set(load);
|
||||
}
|
||||
needLoad.clear();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
currentLive.set(range);
|
||||
needLoad.set(range);
|
||||
}
|
||||
}
|
||||
|
||||
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
|
||||
RegisterName load = RegisterName(needLoad.get(l));
|
||||
if (willSpill.test(load))
|
||||
insertLoadBefore(instructions.first(), load);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertLoadBefore(Instruction& /*instruction*/, RegisterName name)
|
||||
{
|
||||
fprintf(stdout, "will insert load for range %d\n", name);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertStoreAfter(Instruction& /*instruction*/, RegisterName name)
|
||||
{
|
||||
fprintf(stdout, "will insert store for range %d\n", name);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::calculateSpillCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet live(pool, rangeCount);
|
||||
SparseSet needLoad(pool, rangeCount);
|
||||
SparseSet mustSpill(pool, rangeCount);
|
||||
|
||||
SparseSet alreadyStored(pool, rangeCount); // FIX: should get this from previous spilling.
|
||||
|
||||
SpillCost* cost = new SpillCost[rangeCount];
|
||||
memset(cost, '\0', rangeCount * sizeof(SpillCost));
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
double weight = doLog10(node.loopDepth);
|
||||
|
||||
needLoad.clear();
|
||||
live = liveOut[n];
|
||||
mustSpill = live;
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName range = name2range[definePtr->getRegisterName()];
|
||||
|
||||
if (needLoad.test(range))
|
||||
if (!mustSpill.test(range))
|
||||
cost[range].infinite = true;
|
||||
|
||||
if ((false /* !rematerializable(range) */ || !needLoad.test(range)) && !alreadyStored.test(range))
|
||||
cost[range].stores += weight;
|
||||
|
||||
needLoad.clear(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy)
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
if (!live.test(name2range[usePtr->getRegisterName()])) {
|
||||
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
|
||||
Uint32 range = needLoad.get(l);
|
||||
cost[range].loads += weight;
|
||||
mustSpill.set(range);
|
||||
}
|
||||
needLoad.clear();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
live.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
|
||||
live.set(range);
|
||||
needLoad.set(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
assert(defineBegin != defineEnd && defineBegin[0].isRegister());
|
||||
|
||||
RegisterName source = name2range[useBegin[0].getRegisterName()];
|
||||
RegisterName destination = name2range[defineBegin[0].getRegisterName()];
|
||||
|
||||
cost[source].copies += weight;
|
||||
cost[destination].copies += weight;
|
||||
}
|
||||
}
|
||||
|
||||
for (SparseSet::iterator s = needLoad.begin(); !needLoad.done(s); s = needLoad.advance(s))
|
||||
cost[needLoad.get(s)].loads += weight;
|
||||
}
|
||||
|
||||
for (Uint32 r = 0; r < rangeCount; r++) {
|
||||
SpillCost& c = cost[r];
|
||||
c.cost = 2 * (c.loads + c.stores) - c.copies;
|
||||
}
|
||||
|
||||
registerAllocator.spillCost = cost;
|
||||
}
|
||||
|
||||
#endif // _SPILLING_H_
|
||||
239
mozilla/ef/Compiler/RegisterAllocator/Splits.h
Normal file
239
mozilla/ef/Compiler/RegisterAllocator/Splits.h
Normal file
@@ -0,0 +1,239 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SPLITS_H_
|
||||
#define _SPLITS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Splits
|
||||
{
|
||||
static void calculateSplitCosts(RegisterAllocator& registerAllocator);
|
||||
static bool findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range);
|
||||
static void insertSplitCode(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
struct SplitCost
|
||||
{
|
||||
double loads;
|
||||
double stores;
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Splits<RegisterPressure>::insertSplitCode(RegisterAllocator& /*registerAllocator*/)
|
||||
{
|
||||
// FIX
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Splits<RegisterPressure>::findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
NameLinkedList** neighborsWithColor = new(pool) NameLinkedList*[6]; // FIX
|
||||
memset(neighborsWithColor, '\0', 6 * sizeof(NameLinkedList*));
|
||||
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = vector->count - 1; i >=0; --i) {
|
||||
RegisterName neighbor = vector->neighbors[i];
|
||||
RegisterName c = color[neighbor];
|
||||
|
||||
if (c < 6) { // FIX
|
||||
NameLinkedList* node = new(pool) NameLinkedList();
|
||||
node->name = neighbor;
|
||||
node->next = neighborsWithColor[c];
|
||||
neighborsWithColor[c] = node;
|
||||
}
|
||||
}
|
||||
|
||||
bool splitAroundName = true;
|
||||
|
||||
LiveRangeGraph<RegisterPressure>& lGraph = registerAllocator.lGraph;
|
||||
RegisterName bestColor = RegisterName(6); // FIX
|
||||
double bestCost = registerAllocator.spillCost[range].cost;
|
||||
SplitCost* splitCost = registerAllocator.splitCost;
|
||||
|
||||
for (RegisterName i = RegisterName(0); i < 6; i = RegisterName(i + 1)) { // FIX
|
||||
|
||||
double splitAroundNameCost = 0.0;
|
||||
bool canSplitAroundName = true;
|
||||
|
||||
SplitCost& sCost = splitCost[range];
|
||||
double addedCost = 2.0 * (sCost.stores + sCost.loads);
|
||||
|
||||
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
|
||||
RegisterName neighbor = node->name;
|
||||
if (lGraph.haveEdge(neighbor, range)) {
|
||||
canSplitAroundName = false;
|
||||
break;
|
||||
} else
|
||||
splitAroundNameCost += addedCost;
|
||||
}
|
||||
if (canSplitAroundName && splitAroundNameCost < bestCost) {
|
||||
bestCost = splitAroundNameCost;
|
||||
bestColor = i;
|
||||
splitAroundName = true;
|
||||
}
|
||||
|
||||
double splitAroundColorCost = 0.0;
|
||||
bool canSplitAroundColor = true;
|
||||
|
||||
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
|
||||
RegisterName neighbor = node->name;
|
||||
if (lGraph.haveEdge(range, neighbor)) {
|
||||
canSplitAroundColor = false;
|
||||
break;
|
||||
} else {
|
||||
SplitCost& sCost = splitCost[neighbor];
|
||||
double addedCost = 2.0 * (sCost.stores + sCost.loads);
|
||||
splitAroundColorCost += addedCost;
|
||||
}
|
||||
}
|
||||
if (canSplitAroundColor && splitAroundColorCost < bestCost) {
|
||||
bestCost = splitAroundColorCost;
|
||||
bestColor = i;
|
||||
splitAroundName = false;
|
||||
}
|
||||
}
|
||||
if (bestColor < RegisterName(6)) {
|
||||
color[range] = bestColor;
|
||||
registerAllocator.splitFound = true;
|
||||
|
||||
NameLinkedList** splitAround = registerAllocator.splitAround;
|
||||
|
||||
if (splitAroundName)
|
||||
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
|
||||
NameLinkedList* newNode = new(pool) NameLinkedList();
|
||||
newNode->name = node->name;
|
||||
newNode->next = splitAround[range];
|
||||
splitAround[range] = newNode;
|
||||
}
|
||||
else
|
||||
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
|
||||
NameLinkedList* newNode = new(pool) NameLinkedList();
|
||||
RegisterName neighbor = node->name;
|
||||
newNode->name = range;
|
||||
newNode->next = splitAround[neighbor];
|
||||
splitAround[neighbor] = newNode;
|
||||
}
|
||||
|
||||
trespass("Found a split");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Splits<RegisterPressure>::calculateSplitCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
SplitCost* splitCost = new(pool) SplitCost[rangeCount];
|
||||
memset(splitCost, '\0', rangeCount * sizeof(SplitCost));
|
||||
|
||||
SparseSet live(pool, rangeCount);
|
||||
RegisterPressure::Set* liveIn = registerAllocator.liveness.liveIn;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
double weight = doLog10(node.loopDepth);
|
||||
|
||||
live = liveOut[n];
|
||||
|
||||
ControlEdge* successorsEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++) {
|
||||
ControlNode& successor = successorsPtr->getTarget();
|
||||
|
||||
if (successor.getControlKind() != ckEnd) {
|
||||
RegisterPressure::Set& successorLiveIn = liveIn[successor.dfsNum];
|
||||
|
||||
for (SparseSet::iterator i = live.begin(); !live.done(i); i = live.advance(i)) {
|
||||
RegisterName name = RegisterName(live.get(i));
|
||||
if (!successorLiveIn.test(name))
|
||||
splitCost[name].loads += doLog10(successor.loopDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
splitCost[name2range[definePtr->getRegisterName()]].stores += weight;
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
if (!live.test(range)) {
|
||||
if (&instruction != &instructions.last())
|
||||
splitCost[range].loads += weight;
|
||||
else {
|
||||
ControlEdge* successorsEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++)
|
||||
splitCost[range].loads += doLog10(successorsPtr->getTarget().loopDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
live.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
live.set(name2range[usePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
NameLinkedList** splitAround = new(pool) NameLinkedList*[rangeCount];
|
||||
memset(splitAround, '\0', rangeCount * sizeof(NameLinkedList*));
|
||||
registerAllocator.splitAround = splitAround;
|
||||
|
||||
registerAllocator.splitCost = splitCost;
|
||||
registerAllocator.splitFound = false;
|
||||
}
|
||||
|
||||
#endif // _SPLITS_H_
|
||||
186
mozilla/ef/Compiler/RegisterAllocator/Timer.cpp
Normal file
186
mozilla/ef/Compiler/RegisterAllocator/Timer.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashTable.h"
|
||||
#include "Timer.h"
|
||||
#include "Pool.h"
|
||||
|
||||
static Pool pool; // Pool for the Timer class.
|
||||
static HashTable<TimerEntry*> timerEntries(pool); // Timers hashtable.
|
||||
|
||||
const nTimersInABlock = 128; // Number of timers in a block.
|
||||
static PRTime *timers = new(pool) PRTime[nTimersInABlock]; // A block of timers.
|
||||
static Uint8 nextTimer = 0; // nextAvailableTimer.
|
||||
|
||||
//
|
||||
// Calibrate the call to PR_Now().
|
||||
//
|
||||
static PRTime calibrate()
|
||||
{
|
||||
PRTime t = PR_Now();
|
||||
PRTime& a = *new(pool) PRTime();
|
||||
|
||||
// Call 10 times the PR_Now() function.
|
||||
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
|
||||
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
|
||||
t = (PR_Now() - t + 9) / 10;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static PRTime adjust = calibrate();
|
||||
|
||||
//
|
||||
// Return the named timer..
|
||||
//
|
||||
TimerEntry& Timer::getTimerEntry(const char* name)
|
||||
{
|
||||
if (!timerEntries.exists(name)) {
|
||||
TimerEntry* newEntry = new(pool) TimerEntry();
|
||||
newEntry->accumulator = 0;
|
||||
newEntry->running = false;
|
||||
timerEntries.add(name, newEntry);
|
||||
}
|
||||
|
||||
return *timerEntries[name];
|
||||
}
|
||||
|
||||
//
|
||||
// Return a reference to a new timer.
|
||||
//
|
||||
PRTime& Timer::getNewTimer()
|
||||
{
|
||||
if (nextTimer >= nTimersInABlock) {
|
||||
timers = new(pool) PRTime[nTimersInABlock];
|
||||
nextTimer = 0;
|
||||
}
|
||||
return timers[nextTimer++];
|
||||
}
|
||||
|
||||
static Uint32 timersAreFrozen = 0;
|
||||
|
||||
//
|
||||
// Start the named timer.
|
||||
//
|
||||
void Timer::start(const char* name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
PR_ASSERT(!timer.running);
|
||||
|
||||
timer.accumulator = 0;
|
||||
timer.running = true;
|
||||
timer.done = false;
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
//
|
||||
// Stop the named timer.
|
||||
//
|
||||
void Timer::stop(const char* name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
PR_ASSERT(timer.running);
|
||||
timer.running = false;
|
||||
timer.done = true;
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
//
|
||||
// Freeze all the running timers.
|
||||
//
|
||||
void Timer::freezeTimers()
|
||||
{
|
||||
PRTime when = PR_Now() - adjust;
|
||||
|
||||
if (timersAreFrozen == 0) {
|
||||
Vector<TimerEntry*> entries = timerEntries;
|
||||
Uint32 count = entries.size();
|
||||
|
||||
for (Uint32 i = 0; i < count; i++) {
|
||||
TimerEntry& entry = *entries[i];
|
||||
if (entry.running) {
|
||||
entry.accumulator += (when - *entry.startTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
timersAreFrozen++;
|
||||
}
|
||||
|
||||
//
|
||||
// Unfreeze all the running timers.
|
||||
//
|
||||
void Timer::unfreezeTimers()
|
||||
{
|
||||
PR_ASSERT(timersAreFrozen != 0);
|
||||
timersAreFrozen--;
|
||||
|
||||
if (timersAreFrozen == 0) {
|
||||
Vector<TimerEntry *> entries = timerEntries;
|
||||
Uint32 count = entries.size();
|
||||
|
||||
PRTime& newStart = getNewTimer();
|
||||
|
||||
for (Uint32 i = 0; i < count; i++) {
|
||||
TimerEntry& entry = *entries[i];
|
||||
if (entry.running) {
|
||||
entry.startTime = &newStart;
|
||||
}
|
||||
}
|
||||
|
||||
newStart = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Print the named timer in the file f.
|
||||
//
|
||||
void Timer::print(FILE* f, const char *name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
|
||||
PR_ASSERT(timer.done);
|
||||
PRTime elapsed = timer.accumulator;
|
||||
|
||||
if (elapsed >> 32) {
|
||||
fprintf(f, "[timer %s out of range]\n", name);
|
||||
} else {
|
||||
fprintf(f, "[%dus in %s]\n", Uint32(elapsed), name);
|
||||
}
|
||||
fflush(f);
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
80
mozilla/ef/Compiler/RegisterAllocator/Timer.h
Normal file
80
mozilla/ef/Compiler/RegisterAllocator/Timer.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashTable.h"
|
||||
#include "prtime.h"
|
||||
|
||||
//
|
||||
// Naming convention:
|
||||
// As the class Timer contains only static methods, the timer's name should start with the
|
||||
// module name. Otherwise starting 2 timers with the same name will assert.
|
||||
//
|
||||
|
||||
#ifndef NO_TIMER
|
||||
|
||||
struct TimerEntry
|
||||
{
|
||||
PRTime *startTime; // Current time when we start the timer.
|
||||
PRTime accumulator; // Time spent in this timer.
|
||||
bool running; // True if the timer is running.
|
||||
bool done; // True if the timer was running and was stopped.
|
||||
};
|
||||
|
||||
class Timer
|
||||
{
|
||||
private:
|
||||
|
||||
// Return the named timer.
|
||||
static TimerEntry& getTimerEntry(const char* name);
|
||||
// Return a reference to a new Timer.
|
||||
static PRTime& getNewTimer();
|
||||
|
||||
public:
|
||||
|
||||
// Start the timer.
|
||||
static void start(const char* name);
|
||||
// Stop the timer.
|
||||
static void stop(const char* name);
|
||||
// Freeze all the running timers.
|
||||
static void freezeTimers();
|
||||
// Unfreeze all the running timers.
|
||||
static void unfreezeTimers();
|
||||
// Print the timer.
|
||||
static void print(FILE* f, const char *name);
|
||||
};
|
||||
|
||||
inline void startTimer(const char* name) {Timer::start(name);}
|
||||
inline void stopTimer(const char* name) {Timer::stop(name); Timer::print(stdout, name);}
|
||||
#define START_TIMER_SAFE Timer::freezeTimers();
|
||||
#define END_TIMER_SAFE Timer::unfreezeTimers();
|
||||
#define TIMER_SAFE(x) START_TIMER_SAFE x; END_TIMER_SAFE
|
||||
|
||||
#else /* NO_TIMER */
|
||||
|
||||
inline void startTimer(const char* /*name*/) {}
|
||||
inline void stopTimer(const char* /*name*/) {}
|
||||
#define START_TIMER_SAFE
|
||||
#define END_TIMER_SAFE
|
||||
#define TIMER_SAFE(x) x;
|
||||
|
||||
#endif /* NO_TIMER */
|
||||
#endif /* _TIMER_H_ */
|
||||
40
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.cpp
Normal file
40
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "Instruction.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegister -
|
||||
|
||||
#ifdef MANUAL_TEMPLATES
|
||||
template class IndexedPool<VirtualRegister>;
|
||||
#endif
|
||||
|
||||
// Set the defining instruction.
|
||||
//
|
||||
void VirtualRegister::setDefiningInstruction(Instruction& instruction)
|
||||
{
|
||||
if (definingInstruction != NULL) {
|
||||
if ((instruction.getFlags() & ifCopy) && (definingInstruction->getFlags() & ifPhiNode))
|
||||
return;
|
||||
}
|
||||
definingInstruction = &instruction;
|
||||
}
|
||||
|
||||
116
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.h
Normal file
116
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _VIRTUAL_REGISTER_H_
|
||||
#define _VIRTUAL_REGISTER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "IndexedPool.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "RegisterTypes.h"
|
||||
#include "RegisterClass.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegister - 24b
|
||||
|
||||
class Instruction;
|
||||
|
||||
class VirtualRegister : public IndexedObject<VirtualRegister>
|
||||
{
|
||||
public:
|
||||
|
||||
Instruction* definingInstruction; // Instruction defining this VR.
|
||||
|
||||
// Initialize a VR of the given classKind.
|
||||
VirtualRegister(RegisterClassKind /*classKind*/) : definingInstruction(NULL) {}
|
||||
|
||||
// Return the defining instruction for this VR.
|
||||
Instruction* getDefiningInstruction() const {return definingInstruction;}
|
||||
// Set the defining instruction.
|
||||
void setDefiningInstruction(Instruction& insn);
|
||||
};
|
||||
|
||||
// Return true if the VirtualRegisters are equals. The only way 2 VRs can be equal is if
|
||||
// they have the same index. If they have the same index then they are at the same
|
||||
// address in the indexed pool.
|
||||
//
|
||||
inline bool operator == (const VirtualRegister& regA, const VirtualRegister& regB) {return ®A == ®B;}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegisterManager -
|
||||
|
||||
struct PreColoredRegister
|
||||
{
|
||||
RegisterID id;
|
||||
RegisterName color;
|
||||
};
|
||||
|
||||
class VirtualRegisterManager
|
||||
{
|
||||
private:
|
||||
|
||||
IndexedPool<VirtualRegister> registerPool;
|
||||
PreColoredRegister machineRegister[6];
|
||||
|
||||
public:
|
||||
VirtualRegisterManager()
|
||||
{
|
||||
for (Uint32 i = 0; i < 6; i++)
|
||||
machineRegister[i].id = invalidID;
|
||||
}
|
||||
|
||||
// Return the VirtualRegister at the given index.
|
||||
VirtualRegister& getVirtualRegister(RegisterName name) const {return registerPool.get(name);}
|
||||
|
||||
// Return a new VirtualRegister.
|
||||
RegisterID newVirtualRegister(RegisterClassKind classKind)
|
||||
{
|
||||
VirtualRegister& vReg = *new(registerPool) VirtualRegister(classKind);
|
||||
RegisterID rid;
|
||||
|
||||
setName(rid, RegisterName(vReg.getIndex()));
|
||||
setClass(rid, classKind);
|
||||
return rid;
|
||||
}
|
||||
|
||||
RegisterID newMachineRegister(RegisterName name, RegisterClassKind classKind)
|
||||
{
|
||||
RegisterID rid = machineRegister[name].id;
|
||||
|
||||
if (rid == invalidID) {
|
||||
rid = newVirtualRegister(classKind);
|
||||
DEBUG_ONLY(setMachineRegister(rid));
|
||||
machineRegister[name].id = rid;
|
||||
machineRegister[name].color = name;
|
||||
}
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
PreColoredRegister* getMachineRegistersBegin() const {return (PreColoredRegister*) machineRegister;} // FIX
|
||||
PreColoredRegister* getMachineRegistersEnd() const {return (PreColoredRegister*) &machineRegister[6];} // FIX
|
||||
|
||||
// Return the VirtualRegister universe size.
|
||||
Uint32 getSize() {return registerPool.getSize();}
|
||||
|
||||
void setSize(Uint32 size) {registerPool.setSize(size);}
|
||||
};
|
||||
|
||||
#endif // _VIRTUAL_REGISTER_H_
|
||||
@@ -1,36 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public idl src
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:widget directory
|
||||
#
|
||||
|
||||
nsIFontEnumerator.idl
|
||||
nsIFontList.idl
|
||||
nsIScriptableRegion.idl
|
||||
nsIScreen.idl
|
||||
nsIScreenManager.idl
|
||||
nsIPrintOptions.idl
|
||||
nsIPrintSettings.idl
|
||||
@@ -1,44 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx
|
||||
XPIDL_MODULE = gfx
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIFontEnumerator.idl \
|
||||
nsIFontList.idl \
|
||||
nsIScriptableRegion.idl \
|
||||
nsIGraphics.idl \
|
||||
nsIScreen.idl \
|
||||
nsIScreenManager.idl \
|
||||
nsIPrintOptions.idl \
|
||||
nsIPrintSettings.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
#!/usr/local/bin/perl
|
||||
|
||||
require "find.pl";
|
||||
|
||||
$uuid = 0x6f7652e0;
|
||||
$format = "{ 0x%x, 0xee43, 0x11d1, \\\
|
||||
{ 0x9c, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }";
|
||||
$pattern = "--- IID GOES HERE ---";
|
||||
$mydir = cwd();
|
||||
|
||||
sub replaceText {
|
||||
local ($oldname) = $_;
|
||||
local ($newname) = $_;
|
||||
local ($found) = 0;
|
||||
local ($tempname) = $oldname.'.orig';
|
||||
local ($replacement);
|
||||
|
||||
if (-T $oldname && -s $oldname) {
|
||||
open(FILE, "<$oldname")
|
||||
|| die "Unable to open $oldname\n";
|
||||
while (<FILE>) {
|
||||
if (/$pattern/) {
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
|
||||
if ($found) {
|
||||
print "Setting IID for file: ", $oldname, "\n";
|
||||
rename($oldname, $tempname)
|
||||
|| die "Unable to rename $oldname as $tempname";
|
||||
open(REPLACEFILE, ">$newname")
|
||||
|| die "Unable to open $newname for writing\n";
|
||||
|
||||
open(SEARCHFILE, "<$tempname")
|
||||
|| die "Unable to open $tempname\n";
|
||||
|
||||
while (<SEARCHFILE>) {
|
||||
if (/$pattern/) {
|
||||
$replacement = sprintf($format, $uuid++);
|
||||
s/$pattern/$replacement /g;
|
||||
}
|
||||
print REPLACEFILE;
|
||||
}
|
||||
close(SEARCHFILE);
|
||||
close(REPLACEFILE);
|
||||
if (-z $newname) {
|
||||
die "$newname has zero size\n."
|
||||
."Restore manually from $tempname\n";
|
||||
} else {
|
||||
unlink($tempname);
|
||||
}
|
||||
|
||||
warn "$name: Renaming as $newname\n" if $newname ne $oldname;
|
||||
|
||||
$_ = $oldname;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($newname ne $oldname) {
|
||||
warn "$name: Renaming as $newname\n";
|
||||
rename($oldname, $newname) || warn "Unable to rename $oldname\n";
|
||||
}
|
||||
$_ = $oldname;
|
||||
}
|
||||
|
||||
eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
|
||||
if $running_under_some_shell;
|
||||
|
||||
# Traverse desired filesystems
|
||||
$dont_use_nlink = 1;
|
||||
|
||||
if (!$ARGV[0]) {
|
||||
&find('.');
|
||||
}
|
||||
else {
|
||||
foreach $file (@ARGV) {
|
||||
chdir $mydir
|
||||
&find($file);
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
sub wanted {
|
||||
/^nsIDOM.*\.h$/ &&
|
||||
&replaceText($name);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
DEFINES=-D_IMPL_NS_UI
|
||||
MODULE=gfx
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIFontEnumerator.idl \
|
||||
.\nsIFontList.idl \
|
||||
.\nsIScriptableRegion.idl \
|
||||
.\nsIScreen.idl \
|
||||
.\nsIScreenManager.idl \
|
||||
.\nsIPrintOptions.idl \
|
||||
.\nsIPrintSettings.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Erik van der Poel
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(a6cf9114-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIFontEnumerator : nsISupports
|
||||
{
|
||||
/**
|
||||
* Return a sorted array of the names of all installed fonts.
|
||||
*
|
||||
* @param aCount returns number of names returned
|
||||
* @param aResult returns array of names
|
||||
* @return void
|
||||
*/
|
||||
void EnumerateAllFonts(out PRUint32 aCount,
|
||||
[retval, array, size_is(aCount)] out wstring aResult);
|
||||
|
||||
/**
|
||||
* Return a sorted array of names of fonts that support the given language
|
||||
* group and are suitable for use as the given CSS generic font.
|
||||
*
|
||||
* @param aLangGroup language group
|
||||
* @param aGeneric CSS generic font
|
||||
* @param aCount returns number of names returned
|
||||
* @param aResult returns array of names
|
||||
* @return void
|
||||
*/
|
||||
void EnumerateFonts(in string aLangGroup, in string aGeneric,
|
||||
out PRUint32 aCount, [retval, array, size_is(aCount)] out wstring aResult);
|
||||
/*
|
||||
@param aLangGroup language group
|
||||
@return bool do we have a font for this language group
|
||||
*/
|
||||
void HaveFontFor(in string aLangGroup, [retval] out boolean aResult);
|
||||
|
||||
/*
|
||||
* update the global font list
|
||||
* return true if font list is changed
|
||||
*/
|
||||
boolean updateFontList();
|
||||
};
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Stell <bstell@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
/**
|
||||
* The nsIFontList interface provides an application the
|
||||
* necessary information so that the user can select the font to use
|
||||
* as the default style sheet. This is used if the style sheet is
|
||||
* missing or does not specify a font.
|
||||
* <P>Font lists are specified per language group.
|
||||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(702909c6-1dd2-11b2-b833-8a740f643539)]
|
||||
interface nsIFontList : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the list of available fonts for a language group
|
||||
* and for use as the given CSS generic font.
|
||||
*
|
||||
* @param aLangGroup limits the fonts to fonts in a language
|
||||
* group; eg: x-western (American/Western European),
|
||||
* ar (Arabic), el (Greek), he (Hebrew), ja (Japanese),
|
||||
* ko (Korean), th (Thai), tr (Turkish),
|
||||
* x-baltic (Baltic), x-central-euro (Eastern European),
|
||||
* x-cyrillic (Russian), zh-CN (China), zh-TW (Taiwan)
|
||||
*
|
||||
* @param aFontType limits the fonts to the fonts with this CSS
|
||||
* generic font type; eg: serif, sans-serif, cursive,
|
||||
* fantasy, monospace.
|
||||
*
|
||||
* @return a simple enumerator of the available fonts for a
|
||||
* language group / generic type. These strings are
|
||||
* the text supplied by the operating system's font
|
||||
* system.
|
||||
*/
|
||||
nsISimpleEnumerator availableFonts(in wstring aLangGroup,
|
||||
in wstring aFontType);
|
||||
};
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
typedef unsigned long nscolor;
|
||||
typedef long nscoord;
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
*/
|
||||
[scriptable, uuid(812EAE54-1DD2-11B2-B17B-D0ACC700F975)]
|
||||
interface nsIGraphics : nsISupports
|
||||
{
|
||||
/**
|
||||
* The color used to paint with.
|
||||
*/
|
||||
attribute nscolor color;
|
||||
|
||||
/**
|
||||
* Clipping.
|
||||
*/
|
||||
void clipRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
|
||||
/**
|
||||
* Primitives.
|
||||
*/
|
||||
void drawLine(in nscoord x1, in nscoord y1, in nscoord x2, in nscoord y2);
|
||||
|
||||
void drawRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
void fillRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
void invertRect(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
|
||||
void drawEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
void fillEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
void invertEllipse(in nscoord x, in nscoord y, in nscoord width, in nscoord height);
|
||||
|
||||
void drawArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
|
||||
void fillArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
|
||||
void invertArc(in nscoord x, in nscoord y, in nscoord width, in nscoord height, in float startAngle, in float endAngle);
|
||||
|
||||
|
||||
void drawPolygon(in unsigned long count, [array, size_is(count)] in long points);
|
||||
void fillPolygon(in unsigned long count, [array, size_is(count)] in long points);
|
||||
void invertPolygon(in unsigned long count, [array, size_is(count)] in long points);
|
||||
|
||||
void drawString(in wstring text, in nscoord x, in nscoord y);
|
||||
|
||||
void setFont(in wstring name, in nscoord size);
|
||||
|
||||
/**
|
||||
* Stack of graphics states.
|
||||
*/
|
||||
void gsave();
|
||||
void grestore();
|
||||
};
|
||||
@@ -1,284 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Don Cone <dcone@netscape.com>
|
||||
* Jessica Blanco <jblanco@us.ibm.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIPrintSettings.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsFont.h"
|
||||
%}
|
||||
|
||||
interface nsISimpleEnumerator;
|
||||
|
||||
/**
|
||||
* Native types
|
||||
*/
|
||||
[ref] native nsNativeFontRef(nsFont);
|
||||
[ref] native nsNativeStringRef(nsString);
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(CAE87E20-479E-11d4-A856-00105A183419)]
|
||||
|
||||
interface nsIPrintOptions : nsISupports
|
||||
{
|
||||
/* Print Option Flags for Bit Field*/
|
||||
const long kOptPrintOddPages = 0x00000001;
|
||||
const long kOptPrintEvenPages = 0x00000002;
|
||||
const long kPrintOptionsEnableSelectionRB = 0x00000004;
|
||||
|
||||
/* Print Range Enums */
|
||||
const long kRangeAllPages = 0;
|
||||
const long kRangeSpecifiedPageRange = 1;
|
||||
const long kRangeSelection = 2;
|
||||
const long kRangeFocusFrame = 3;
|
||||
|
||||
/* Justification Enums */
|
||||
const long kJustLeft = 0;
|
||||
const long kJustCenter = 1;
|
||||
const long kJustRight = 2;
|
||||
|
||||
/**
|
||||
* Page Size Constants (NOTE: These have been deprecated!);
|
||||
*/
|
||||
const short kLetterPaperSize = 0;
|
||||
const short kLegalPaperSize = 1;
|
||||
const short kExecutivePaperSize = 2;
|
||||
const short kA4PaperSize = 3;
|
||||
const short kA3PaperSize = 4;
|
||||
|
||||
/**
|
||||
* FrameSet Default Type Constants
|
||||
*/
|
||||
const short kUseInternalDefault = 0;
|
||||
const short kUseSettingWhenPossible = 1;
|
||||
|
||||
/**
|
||||
* Page Size Type Constants
|
||||
*/
|
||||
const short kPaperSizeNativeData = 0;
|
||||
const short kPaperSizeDefined = 1;
|
||||
|
||||
/**
|
||||
* Page Size Unit Constants
|
||||
*/
|
||||
const short kPaperSizeInches = 0;
|
||||
const short kPaperSizeMillimeters = 1;
|
||||
|
||||
/**
|
||||
* Orientation Constants
|
||||
*/
|
||||
const short kPortraitOrientation = 0;
|
||||
const short kLandscapeOrientation = 1;
|
||||
|
||||
/**
|
||||
* Print Frame Constants
|
||||
*/
|
||||
const short kNoFrames = 0;
|
||||
const short kFramesAsIs = 1;
|
||||
const short kSelectedFrame = 2;
|
||||
const short kEachFrameSep = 3;
|
||||
|
||||
/**
|
||||
* How to Enable Frame Set Printing Constants
|
||||
*/
|
||||
const short kFrameEnableNone = 0;
|
||||
const short kFrameEnableAll = 1;
|
||||
const short kFrameEnableAsIsAndEach = 2;
|
||||
|
||||
/**
|
||||
* Show Native Print Options dialog, this may not be supported on all platforms
|
||||
*/
|
||||
void ShowNativeDialog();
|
||||
|
||||
/**
|
||||
* Set PrintOptions
|
||||
*/
|
||||
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
|
||||
|
||||
/**
|
||||
* Get PrintOptions
|
||||
*/
|
||||
PRBool GetPrintOptions(in PRInt32 aType);
|
||||
|
||||
/**
|
||||
* Set PrintOptions Bit field
|
||||
*/
|
||||
PRInt32 GetPrintOptionsBits();
|
||||
|
||||
/**
|
||||
* Read Prefs
|
||||
*/
|
||||
void ReadPrefs();
|
||||
|
||||
/**
|
||||
* Write Prefs
|
||||
*/
|
||||
void WritePrefs();
|
||||
|
||||
/**
|
||||
* Creates a new PrintSettnigs Object
|
||||
* and initializes it from prefs
|
||||
*/
|
||||
nsIPrintSettings CreatePrintSettings();
|
||||
|
||||
/**
|
||||
* Creates a new PrintSettnigs Object if it doesn't exist
|
||||
* otherwise it always hand back the same one.
|
||||
* This is THE global PrintSettings
|
||||
*/
|
||||
readonly attribute nsIPrintSettings globalPrintSettings;
|
||||
|
||||
/**
|
||||
* Initialize the values in the PrintSettings from Prefs
|
||||
*/
|
||||
void InitPrintSettingsFromPrefs(in nsIPrintSettings aPO);
|
||||
|
||||
/**
|
||||
* Data Members
|
||||
*/
|
||||
attribute long startPageRange;
|
||||
attribute long endPageRange;
|
||||
|
||||
attribute double marginTop; /* these are in inches */
|
||||
attribute double marginLeft;
|
||||
attribute double marginBottom;
|
||||
attribute double marginRight;
|
||||
|
||||
attribute double scaling; /* values 0.0 - 1.0 */
|
||||
attribute boolean printBGColors; /* Print Background Colors */
|
||||
attribute boolean printBGImages; /* Print Background Images */
|
||||
|
||||
attribute short printRange;
|
||||
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute wstring headerStrLeft;
|
||||
attribute wstring headerStrCenter;
|
||||
attribute wstring headerStrRight;
|
||||
|
||||
attribute wstring footerStrLeft;
|
||||
attribute wstring footerStrCenter;
|
||||
attribute wstring footerStrRight;
|
||||
|
||||
attribute short howToEnableFrameUI;
|
||||
attribute boolean isCancelled;
|
||||
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not*/
|
||||
attribute short printFrameType;
|
||||
attribute boolean printSilent; /* print without putting up the dialog */
|
||||
|
||||
attribute nsIPrintSettings printSettingsValues; /* used copy the values to/from the settings obj*/
|
||||
attribute nsIPrintSettings printSettings; /* used to set and get the current object */
|
||||
|
||||
/* Additional XP Related */
|
||||
attribute short paperSizeType; /* use native data or is defined here */
|
||||
attribute short paperData; /* native data value */
|
||||
attribute double paperWidth; /* width of the paper in inches or mm */
|
||||
attribute double paperHeight; /* height of the paper in inches or mm */
|
||||
attribute short paperSizeUnit; /* paper is in inches or mm */
|
||||
|
||||
attribute long paperSize; /* This has been deprecated */
|
||||
|
||||
attribute boolean printReversed;
|
||||
attribute boolean printInColor; /* a false means grayscale */
|
||||
attribute long orientation; /* see orientation consts */
|
||||
attribute wstring printCommand;
|
||||
attribute long numCopies;
|
||||
attribute wstring printerName;
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
attribute long printPageDelay; /* in milliseconds */
|
||||
|
||||
/* No Script Methods */
|
||||
|
||||
[noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize);
|
||||
|
||||
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
|
||||
[noscript] void SetDefaultFont(in nsNativeFontRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetDefaultFont(in nsNativeFontRef aMargin);
|
||||
|
||||
[noscript] void GetPageSizeInTwips(out long aWidth, out long aHeight);
|
||||
|
||||
/**
|
||||
* available Printers
|
||||
*/
|
||||
nsISimpleEnumerator availablePrinters ();
|
||||
|
||||
/**
|
||||
* display Printer Job Properties dialog
|
||||
*/
|
||||
void displayJobProperties (in wstring aPrinter, in nsIPrintSettings aPrintSettings, out boolean aDisplayed);
|
||||
|
||||
/**
|
||||
* Native data constants
|
||||
*/
|
||||
const short kNativeDataPrintRecord = 0;
|
||||
|
||||
[noscript] voidPtr GetNativeData(in short aDataType);
|
||||
};
|
||||
|
||||
[scriptable, uuid(a6cf9128-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIPrinterEnumerator : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns an array of the names of all installed printers.
|
||||
*
|
||||
* @param aCount returns number of printers returned
|
||||
* @param aResult returns array of names
|
||||
* @return void
|
||||
*/
|
||||
void enumeratePrinters(out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult);
|
||||
|
||||
/* takes printer selected and will display job properties dlg for that printer
|
||||
* returns true if dialog displays
|
||||
*/
|
||||
void displayPropertiesDlg(in wstring aPrinter, in nsIPrintSettings aPrintSettings);
|
||||
|
||||
};
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Don Cone <dcone@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
%{ C++
|
||||
#include "nsMargin.h"
|
||||
#include "nsFont.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* Native types
|
||||
*/
|
||||
[ref] native nsNativeMarginRef(nsMargin);
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(83427530-F790-11d4-A869-00105A183419)]
|
||||
|
||||
interface nsIPrintSettings : nsISupports
|
||||
{
|
||||
|
||||
/* Print Option Flags for Bit Field*/
|
||||
const long kPrintOddPages = 0x00000001;
|
||||
const long kPrintEvenPages = 0x00000002;
|
||||
const long kEnableSelectionRB = 0x00000004;
|
||||
|
||||
/* Print Range Enums */
|
||||
const long kRangeAllPages = 0;
|
||||
const long kRangeSpecifiedPageRange = 1;
|
||||
const long kRangeSelection = 2;
|
||||
const long kRangeFocusFrame = 3;
|
||||
|
||||
/* Justification Enums */
|
||||
const long kJustLeft = 0;
|
||||
const long kJustCenter = 1;
|
||||
const long kJustRight = 2;
|
||||
|
||||
/**
|
||||
* FrameSet Default Type Constants
|
||||
*/
|
||||
const short kUseInternalDefault = 0;
|
||||
const short kUseSettingWhenPossible = 1;
|
||||
|
||||
/**
|
||||
* Page Size Type Constants
|
||||
*/
|
||||
const short kPaperSizeNativeData = 0;
|
||||
const short kPaperSizeDefined = 1;
|
||||
|
||||
/**
|
||||
* Page Size Unit Constants
|
||||
*/
|
||||
const short kPaperSizeInches = 0;
|
||||
const short kPaperSizeMillimeters = 1;
|
||||
|
||||
/**
|
||||
* Orientation Constants
|
||||
*/
|
||||
const short kPortraitOrientation = 0;
|
||||
const short kLandscapeOrientation = 1;
|
||||
|
||||
/**
|
||||
* Print Frame Constants
|
||||
*/
|
||||
const short kNoFrames = 0;
|
||||
const short kFramesAsIs = 1;
|
||||
const short kSelectedFrame = 2;
|
||||
const short kEachFrameSep = 3;
|
||||
|
||||
/**
|
||||
* How to Enable Frame Set Printing Constants
|
||||
*/
|
||||
const short kFrameEnableNone = 0;
|
||||
const short kFrameEnableAll = 1;
|
||||
const short kFrameEnableAsIsAndEach = 2;
|
||||
|
||||
/**
|
||||
* Set PrintOptions
|
||||
*/
|
||||
void SetPrintOptions(in PRInt32 aType, in PRBool aTurnOnOff);
|
||||
|
||||
/**
|
||||
* Get PrintOptions
|
||||
*/
|
||||
PRBool GetPrintOptions(in PRInt32 aType);
|
||||
|
||||
/**
|
||||
* Set PrintOptions Bit field
|
||||
*/
|
||||
PRInt32 GetPrintOptionsBits();
|
||||
|
||||
/**
|
||||
* Returns W/H in Twips from Paper Size H/W
|
||||
*/
|
||||
void GetPageSizeInTwips(out long aWidth, out long aHeight);
|
||||
|
||||
/**
|
||||
* Data Members
|
||||
*/
|
||||
attribute long startPageRange;
|
||||
attribute long endPageRange;
|
||||
|
||||
attribute double marginTop; /* these are in inches */
|
||||
attribute double marginLeft;
|
||||
attribute double marginBottom;
|
||||
attribute double marginRight;
|
||||
|
||||
attribute double scaling; /* values 0.0 - 1.0 */
|
||||
attribute boolean printBGColors; /* Print Background Colors */
|
||||
attribute boolean printBGImages; /* Print Background Images */
|
||||
|
||||
attribute short printRange;
|
||||
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute wstring headerStrLeft;
|
||||
attribute wstring headerStrCenter;
|
||||
attribute wstring headerStrRight;
|
||||
|
||||
attribute wstring footerStrLeft;
|
||||
attribute wstring footerStrCenter;
|
||||
attribute wstring footerStrRight;
|
||||
|
||||
attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */
|
||||
attribute boolean isCancelled; /* indicates whether the print job has been cancelled */
|
||||
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */
|
||||
attribute short printFrameType;
|
||||
attribute boolean printSilent; /* print without putting up the dialog */
|
||||
|
||||
/* Additional XP Related */
|
||||
attribute short paperSizeType; /* use native data or is defined here */
|
||||
attribute short paperData; /* native data value */
|
||||
attribute double paperWidth; /* width of the paper in inches or mm */
|
||||
attribute double paperHeight; /* height of the paper in inches or mm */
|
||||
attribute short paperSizeUnit; /* paper is in inches or mm */
|
||||
|
||||
attribute boolean printReversed;
|
||||
attribute boolean printInColor; /* a false means grayscale */
|
||||
attribute long paperSize; /* see page size consts */
|
||||
attribute long orientation; /* see orientation consts */
|
||||
attribute wstring printCommand;
|
||||
attribute long numCopies;
|
||||
attribute wstring printerName;
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
attribute long printPageDelay; /* in milliseconds */
|
||||
|
||||
/* C++ Helper Functions */
|
||||
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
[noscript] void GetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 2000 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(f728830e-1dd1-11b2-9598-fb9f414f2465)]
|
||||
interface nsIScreen : nsISupports
|
||||
{
|
||||
void GetRect ( out long left, out long top, out long width, out long height );
|
||||
void GetAvailRect ( out long left, out long top, out long width, out long height );
|
||||
|
||||
readonly attribute long pixelDepth;
|
||||
readonly attribute long colorDepth;
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 2000 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIScreen.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(662e7b78-1dd2-11b2-a3d3-fc1e5f5fb9d4)]
|
||||
interface nsIScreenManager : nsISupports
|
||||
{
|
||||
//
|
||||
// Returns the screen that contains the rectangle. If the rect overlaps
|
||||
// multiple screens, it picks the screen with the greatest area of intersection.
|
||||
//
|
||||
// The coordinates are in pixels (not twips) and in screen coordinates.
|
||||
//
|
||||
nsIScreen screenForRect ( in long left, in long top, in long width, in long height ) ;
|
||||
|
||||
// The screen with the menubar/taskbar. This shouldn't be needed very
|
||||
// often.
|
||||
readonly attribute nsIScreen primaryScreen;
|
||||
|
||||
// Holds the number of screens that are available
|
||||
readonly attribute unsigned long numberOfScreens;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,190 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corp. Portions created by Netscape are Copyright (C) 1999 Netscape
|
||||
* Communications Corp. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Pinkerton
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
class nsIRegion;
|
||||
%}
|
||||
|
||||
[ptr] native nsIRegion(nsIRegion);
|
||||
|
||||
|
||||
[scriptable, uuid(82d8f400-5bde-11d3-b033-b27a62766bbc)]
|
||||
interface nsIScriptableRegion : nsISupports
|
||||
{
|
||||
void init ( ) ;
|
||||
|
||||
/**
|
||||
* copy operator equivalent that takes another region
|
||||
*
|
||||
* @param region to copy
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void setToRegion ( in nsIScriptableRegion aRegion );
|
||||
|
||||
/**
|
||||
* copy operator equivalent that takes a rect
|
||||
*
|
||||
* @param aX xoffset of rect to set region to
|
||||
* @param aY yoffset of rect to set region to
|
||||
* @param aWidth width of rect to set region to
|
||||
* @param aHeight height of rect to set region to
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void setToRect ( in long aX, in long aY, in long aWidth, in long aHeight );
|
||||
|
||||
/**
|
||||
* destructively intersect another region with this one
|
||||
*
|
||||
* @param region to intersect
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void intersectRegion ( in nsIScriptableRegion aRegion ) ;
|
||||
|
||||
/**
|
||||
* destructively intersect a rect with this region
|
||||
*
|
||||
* @param aX xoffset of rect to intersect with region
|
||||
* @param aY yoffset of rect to intersect with region
|
||||
* @param aWidth width of rect to intersect with region
|
||||
* @param aHeight height of rect to intersect with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void intersectRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
|
||||
|
||||
/**
|
||||
* destructively union another region with this one
|
||||
*
|
||||
* @param region to union
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void unionRegion ( in nsIScriptableRegion aRegion ) ;
|
||||
|
||||
/**
|
||||
* destructively union a rect with this region
|
||||
*
|
||||
* @param aX xoffset of rect to union with region
|
||||
* @param aY yoffset of rect to union with region
|
||||
* @param aWidth width of rect to union with region
|
||||
* @param aHeight height of rect to union with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void unionRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
|
||||
|
||||
/**
|
||||
* destructively subtract another region with this one
|
||||
*
|
||||
* @param region to subtract
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void subtractRegion ( in nsIScriptableRegion aRegion ) ;
|
||||
|
||||
/**
|
||||
* destructively subtract a rect from this region
|
||||
*
|
||||
* @param aX xoffset of rect to subtract with region
|
||||
* @param aY yoffset of rect to subtract with region
|
||||
* @param aWidth width of rect to subtract with region
|
||||
* @param aHeight height of rect to subtract with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
void subtractRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
|
||||
|
||||
/**
|
||||
* is this region empty? i.e. does it contain any pixels
|
||||
*
|
||||
* @param none
|
||||
* @return returns whether the region is empty
|
||||
*
|
||||
**/
|
||||
|
||||
boolean isEmpty ( ) ;
|
||||
|
||||
/**
|
||||
* == operator equivalent i.e. do the regions contain exactly
|
||||
* the same pixels
|
||||
*
|
||||
* @param region to compare
|
||||
* @return whether the regions are identical
|
||||
*
|
||||
**/
|
||||
|
||||
boolean isEqualRegion ( in nsIScriptableRegion aRegion ) ;
|
||||
|
||||
/**
|
||||
* returns the bounding box of the region i.e. the smallest
|
||||
* rectangle that completely contains the region.
|
||||
*
|
||||
* @param aX out parameter for xoffset of bounding rect for region
|
||||
* @param aY out parameter for yoffset of bounding rect for region
|
||||
* @param aWidth out parameter for width of bounding rect for region
|
||||
* @param aHeight out parameter for height of bounding rect for region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
void getBoundingBox ( out long aX, out long aY, out long aWidth, out long aHeight ) ;
|
||||
|
||||
/**
|
||||
* offsets the region in x and y
|
||||
*
|
||||
* @param xoffset pixel offset in x
|
||||
* @param yoffset pixel offset in y
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
void offset ( in long aXOffset, in long aYOffset ) ;
|
||||
|
||||
/**
|
||||
* does the region intersect the rectangle?
|
||||
*
|
||||
* @param rect to check for containment
|
||||
* @return true if the region intersects the rect
|
||||
*
|
||||
**/
|
||||
|
||||
boolean containsRect ( in long aX, in long aY, in long aWidth, in long aHeight ) ;
|
||||
|
||||
[noscript] readonly attribute nsIRegion region;
|
||||
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
|
||||
%}
|
||||
@@ -1,26 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#if TARGET_CARBON
|
||||
// we can't use the carbon printing session APIs
|
||||
#define PM_USE_SESSION_APIS 0
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
#include "GFXComponentConfig.h"
|
||||
@@ -1,24 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "MacSharedPrefix.h"
|
||||
#include "GFXComponentConfig.h"
|
||||
@@ -1,23 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#define _IMPL_NS_GFX 1
|
||||
@@ -1,24 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "GFXConfig.h"
|
||||
#include "MacPrefix.h"
|
||||
@@ -1,25 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
|
||||
#include "GFXConfig.h"
|
||||
#include "MacPrefix_debug.h"
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..
|
||||
|
||||
DIRS= public src \
|
||||
!if !defined(DISABLE_TESTS)
|
||||
tests \
|
||||
!endif
|
||||
idl
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,30 +0,0 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist:widget directory
|
||||
#
|
||||
|
||||
nsColor.h
|
||||
nsColorNames.h
|
||||
nsColorNameList.h
|
||||
nsCoord.h
|
||||
nsFont.h
|
||||
nsRect.h
|
||||
nsPoint.h
|
||||
nsSize.h
|
||||
nsMargin.h
|
||||
nsTransform2D.h
|
||||
nsIRenderingContext.h
|
||||
nsIFontMetrics.h
|
||||
nsIDeviceContext.h
|
||||
nsIImage.h
|
||||
nsIBlender.h
|
||||
nsGfxCIID.h
|
||||
nsIRegion.h
|
||||
nsDeviceContext.h
|
||||
nsRenderingContextImpl.h
|
||||
nsIDeviceContextSpec.h
|
||||
nsIDeviceContextSpecFactory.h
|
||||
nsIDrawingSurface.h
|
||||
nsRepeater.h
|
||||
nsThemeConstants.h
|
||||
nsITheme.h
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx
|
||||
|
||||
EXPORTS = \
|
||||
imgScaler.h \
|
||||
nsColor.h \
|
||||
nsColorNames.h \
|
||||
nsColorNameList.h \
|
||||
nsCompressedCharMap.h \
|
||||
nsCoord.h \
|
||||
nsFont.h \
|
||||
nsRect.h \
|
||||
nsRepeater.h \
|
||||
nsPoint.h \
|
||||
nsSize.h \
|
||||
nsMargin.h \
|
||||
nsTransform2D.h \
|
||||
nsIRenderingContext.h \
|
||||
nsRenderingContextImpl.h \
|
||||
nsIFontMetrics.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
nsGfxCIID.h \
|
||||
nsIRegion.h \
|
||||
nsDeviceContext.h \
|
||||
nsIDeviceContextSpec.h \
|
||||
nsIDeviceContextSpecFactory.h \
|
||||
nsIDrawingSurface.h \
|
||||
nsITheme.h \
|
||||
nsThemeConstants.h \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXPORTS += nsIPrintingContext.h
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Tomas Mšller
|
||||
* Portions created by Tomas Mšller are
|
||||
* Copyright (C) 2001 Tomas Mšller. Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Tomas Mšller
|
||||
* Tim Rowley <tor@cs.brown.edu>
|
||||
*/
|
||||
|
||||
void RectStretch(long xs1,long ys1,long xs2,long ys2,
|
||||
long xd1,long yd1,long xd2,long yd2,
|
||||
unsigned char *aSrcImage, unsigned aSrcStride,
|
||||
unsigned char *aDstImage, unsigned aDstStride,
|
||||
unsigned aDepth);
|
||||
@@ -1,56 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
EXPORTS = \
|
||||
nsColor.h \
|
||||
nsColorNames.h \
|
||||
nsColorNameList.h \
|
||||
nsCoord.h \
|
||||
nsFont.h \
|
||||
nsRect.h \
|
||||
nsPoint.h \
|
||||
nsSize.h \
|
||||
nsMargin.h \
|
||||
nsTransform2D.h \
|
||||
nsIRenderingContext.h \
|
||||
nsRenderingContextImpl.h \
|
||||
nsIFontMetrics.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
nsGfxCIID.h \
|
||||
nsIRegion.h \
|
||||
nsDeviceContext.h \
|
||||
nsIDeviceContextSpec.h \
|
||||
nsIDeviceContextSpecFactory.h \
|
||||
nsIDrawingSurface.h \
|
||||
nsCompressedCharMap.h \
|
||||
nsThemeConstants.h \
|
||||
nsITheme.h \
|
||||
$(NULL)
|
||||
|
||||
MODULE=gfx
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsColor_h___
|
||||
#define nsColor_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class nsString;
|
||||
class nsAString;
|
||||
|
||||
// A color is a 32 bit unsigned integer with four components: R, G, B
|
||||
// and A.
|
||||
typedef PRUint32 nscolor;
|
||||
|
||||
// Make a color out of r,g,b values. This assumes that the r,g,b values are
|
||||
// properly constrained to 0-255. This also assumes that a is 255.
|
||||
#define NS_RGB(_r,_g,_b) \
|
||||
((nscolor) ((255 << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
|
||||
|
||||
// Make a color out of r,g,b,a values. This assumes that the r,g,b,a
|
||||
// values are properly constrained to 0-255.
|
||||
#define NS_RGBA(_r,_g,_b,_a) \
|
||||
((nscolor) (((_a) << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
|
||||
|
||||
// Extract color components from nscolor
|
||||
#define NS_GET_R(_rgba) ((PRUint8) ((_rgba) & 0xff))
|
||||
#define NS_GET_G(_rgba) ((PRUint8) (((_rgba) >> 8) & 0xff))
|
||||
#define NS_GET_B(_rgba) ((PRUint8) (((_rgba) >> 16) & 0xff))
|
||||
#define NS_GET_A(_rgba) ((PRUint8) (((_rgba) >> 24) & 0xff))
|
||||
|
||||
// Fast approximate division by 255. It has the property that
|
||||
// for all 0 <= n <= 255*255, FAST_DIVIDE_BY_255(n) == n/255.
|
||||
// But it only uses two adds and two shifts instead of an
|
||||
// integer division (which is expensive on many processors).
|
||||
//
|
||||
// equivalent to target=v/255
|
||||
#define FAST_DIVIDE_BY_255(target,v) \
|
||||
PR_BEGIN_MACRO \
|
||||
unsigned tmp_ = v; \
|
||||
target = ((tmp_ << 8) + tmp_ + 255) >> 16; \
|
||||
PR_END_MACRO
|
||||
|
||||
// Blending macro
|
||||
//
|
||||
// equivalent to target=(bg*(255-alpha)+fg*alpha)/255
|
||||
#define MOZ_BLEND(target, bg, fg, alpha) \
|
||||
FAST_DIVIDE_BY_255(target, (bg)*(255-(alpha)) + (fg)*(alpha))
|
||||
|
||||
// Translate a hex string to a color. Return true if it parses ok,
|
||||
// otherwise return false.
|
||||
// This accepts only 3, 6 or 9 digits
|
||||
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aBuf, nscolor* aResult);
|
||||
|
||||
// Translate a hex string to a color. Return true if it parses ok,
|
||||
// otherwise return false.
|
||||
// This version accepts 1 to 9 digits (missing digits are 0)
|
||||
extern "C" NS_GFX_(PRBool) NS_LooseHexToRGB(const nsString& aBuf, nscolor* aResult);
|
||||
|
||||
// Translate a color name to a color. Return true if it parses ok,
|
||||
// otherwise return false.
|
||||
extern "C" NS_GFX_(PRBool) NS_ColorNameToRGB(const nsAString& aBuf, nscolor* aResult);
|
||||
|
||||
// Weird color computing code stolen from winfe which was stolen
|
||||
// from the xfe which was written originally by Eric Bina. So there.
|
||||
extern "C" NS_GFX_(void) NS_Get3DColors(nscolor aResult[2], nscolor aColor);
|
||||
|
||||
// To determin colors based on the background brightness
|
||||
extern "C" NS_GFX_(void) NS_GetSpecial3DColors(nscolor aResult[2],
|
||||
nscolor aBackgroundColor,
|
||||
nscolor aBorderColor);
|
||||
|
||||
// Special method to brighten a Color and have it shift to white when
|
||||
// fully saturated.
|
||||
extern "C" NS_GFX_(nscolor) NS_BrightenColor(nscolor inColor);
|
||||
|
||||
// Special method to darken a Color and have it shift to black when
|
||||
// darkest component underflows
|
||||
extern "C" NS_GFX_(nscolor) NS_DarkenColor(nscolor inColor);
|
||||
|
||||
// Determins brightness for a specific color
|
||||
extern "C" NS_GFX_(int) NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue);
|
||||
|
||||
#endif /* nsColor_h___ */
|
||||
@@ -1,212 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/******
|
||||
|
||||
This file contains the list of all named colors
|
||||
See nsCSSColorNames.h for access to the enum values for colors
|
||||
|
||||
It is designed to be used as inline input to nsCSSColorNames.cpp *only*
|
||||
through the magic of C preprocessing.
|
||||
|
||||
All entires must be enclosed in the macro GFX_COLOR which will have cruel
|
||||
and unusual things done to it
|
||||
|
||||
It is recommended (but not strictly necessary) to keep all entries
|
||||
in alphabetical order
|
||||
|
||||
The first argument to GFX_COLOR is both the enum identifier of the color
|
||||
and the string value
|
||||
The second argument is the sRGBA value for the named color
|
||||
|
||||
'name' entries *must* use only lowercase characters.
|
||||
|
||||
** Break these invarient and bad things will happen. **
|
||||
|
||||
|
||||
******/
|
||||
|
||||
|
||||
GFX_COLOR(aliceblue, NS_RGB(240, 248, 255))
|
||||
GFX_COLOR(antiquewhite, NS_RGB(250, 235, 215))
|
||||
GFX_COLOR(aqua, NS_RGB( 0, 255, 255))
|
||||
GFX_COLOR(aquamarine, NS_RGB(127, 255, 212))
|
||||
GFX_COLOR(azure, NS_RGB(240, 255, 255))
|
||||
GFX_COLOR(beige, NS_RGB(245, 245, 220))
|
||||
GFX_COLOR(bisque, NS_RGB(255, 228, 196))
|
||||
GFX_COLOR(black, NS_RGB( 0, 0, 0))
|
||||
GFX_COLOR(blanchedalmond, NS_RGB(255, 235, 205))
|
||||
GFX_COLOR(blue, NS_RGB( 0, 0, 255))
|
||||
GFX_COLOR(blueviolet, NS_RGB(138, 43, 226))
|
||||
GFX_COLOR(brown, NS_RGB(165, 42, 42))
|
||||
GFX_COLOR(burlywood, NS_RGB(222, 184, 135))
|
||||
GFX_COLOR(cadetblue, NS_RGB( 95, 158, 160))
|
||||
GFX_COLOR(chartreuse, NS_RGB(127, 255, 0))
|
||||
GFX_COLOR(chocolate, NS_RGB(210, 105, 30))
|
||||
GFX_COLOR(coral, NS_RGB(255, 127, 80))
|
||||
GFX_COLOR(cornflowerblue, NS_RGB(100, 149, 237))
|
||||
GFX_COLOR(cornsilk, NS_RGB(255, 248, 220))
|
||||
GFX_COLOR(crimson, NS_RGB(220, 20, 60))
|
||||
GFX_COLOR(cyan, NS_RGB( 0, 255, 255))
|
||||
GFX_COLOR(darkblue, NS_RGB( 0, 0, 139))
|
||||
GFX_COLOR(darkcyan, NS_RGB( 0, 139, 139))
|
||||
GFX_COLOR(darkgoldenrod, NS_RGB(184, 134, 11))
|
||||
GFX_COLOR(darkgray, NS_RGB(169, 169, 169))
|
||||
GFX_COLOR(darkgreen, NS_RGB( 0, 100, 0))
|
||||
GFX_COLOR(darkgrey, NS_RGB(169, 169, 169))
|
||||
GFX_COLOR(darkkhaki, NS_RGB(189, 183, 107))
|
||||
GFX_COLOR(darkmagenta, NS_RGB(139, 0, 139))
|
||||
GFX_COLOR(darkolivegreen, NS_RGB( 85, 107, 47))
|
||||
GFX_COLOR(darkorange, NS_RGB(255, 140, 0))
|
||||
GFX_COLOR(darkorchid, NS_RGB(153, 50, 204))
|
||||
GFX_COLOR(darkred, NS_RGB(139, 0, 0))
|
||||
GFX_COLOR(darksalmon, NS_RGB(233, 150, 122))
|
||||
GFX_COLOR(darkseagreen, NS_RGB(143, 188, 143))
|
||||
GFX_COLOR(darkslateblue, NS_RGB( 72, 61, 139))
|
||||
GFX_COLOR(darkslategray, NS_RGB( 47, 79, 79))
|
||||
GFX_COLOR(darkslategrey, NS_RGB( 47, 79, 79))
|
||||
GFX_COLOR(darkturquoise, NS_RGB( 0, 206, 209))
|
||||
GFX_COLOR(darkviolet, NS_RGB(148, 0, 211))
|
||||
GFX_COLOR(deeppink, NS_RGB(255, 20, 147))
|
||||
GFX_COLOR(deepskyblue, NS_RGB( 0, 191, 255))
|
||||
GFX_COLOR(dimgray, NS_RGB(105, 105, 105))
|
||||
GFX_COLOR(dimgrey, NS_RGB(105, 105, 105))
|
||||
GFX_COLOR(dodgerblue, NS_RGB( 30, 144, 255))
|
||||
GFX_COLOR(firebrick, NS_RGB(178, 34, 34))
|
||||
GFX_COLOR(floralwhite, NS_RGB(255, 250, 240))
|
||||
GFX_COLOR(forestgreen, NS_RGB( 34, 139, 34))
|
||||
GFX_COLOR(fuchsia, NS_RGB(255, 0, 255))
|
||||
GFX_COLOR(gainsboro, NS_RGB(220, 220, 220))
|
||||
GFX_COLOR(ghostwhite, NS_RGB(248, 248, 255))
|
||||
GFX_COLOR(gold, NS_RGB(255, 215, 0))
|
||||
GFX_COLOR(goldenrod, NS_RGB(218, 165, 32))
|
||||
GFX_COLOR(gray, NS_RGB(128, 128, 128))
|
||||
GFX_COLOR(grey, NS_RGB(128, 128, 128))
|
||||
GFX_COLOR(green, NS_RGB( 0, 128, 0))
|
||||
GFX_COLOR(greenyellow, NS_RGB(173, 255, 47))
|
||||
GFX_COLOR(honeydew, NS_RGB(240, 255, 240))
|
||||
GFX_COLOR(hotpink, NS_RGB(255, 105, 180))
|
||||
GFX_COLOR(indianred, NS_RGB(205, 92, 92))
|
||||
GFX_COLOR(indigo, NS_RGB( 75, 0, 130))
|
||||
GFX_COLOR(ivory, NS_RGB(255, 255, 240))
|
||||
GFX_COLOR(khaki, NS_RGB(240, 230, 140))
|
||||
GFX_COLOR(lavender, NS_RGB(230, 230, 250))
|
||||
GFX_COLOR(lavenderblush, NS_RGB(255, 240, 245))
|
||||
GFX_COLOR(lawngreen, NS_RGB(124, 252, 0))
|
||||
GFX_COLOR(lemonchiffon, NS_RGB(255, 250, 205))
|
||||
GFX_COLOR(lightblue, NS_RGB(173, 216, 230))
|
||||
GFX_COLOR(lightcoral, NS_RGB(240, 128, 128))
|
||||
GFX_COLOR(lightcyan, NS_RGB(224, 255, 255))
|
||||
GFX_COLOR(lightgoldenrodyellow, NS_RGB(250, 250, 210))
|
||||
GFX_COLOR(lightgray, NS_RGB(211, 211, 211))
|
||||
GFX_COLOR(lightgreen, NS_RGB(144, 238, 144))
|
||||
GFX_COLOR(lightgrey, NS_RGB(211, 211, 211))
|
||||
GFX_COLOR(lightpink, NS_RGB(255, 182, 193))
|
||||
GFX_COLOR(lightsalmon, NS_RGB(255, 160, 122))
|
||||
GFX_COLOR(lightseagreen, NS_RGB( 32, 178, 170))
|
||||
GFX_COLOR(lightskyblue, NS_RGB(135, 206, 250))
|
||||
GFX_COLOR(lightslategray, NS_RGB(119, 136, 153))
|
||||
GFX_COLOR(lightslategrey, NS_RGB(119, 136, 153))
|
||||
GFX_COLOR(lightsteelblue, NS_RGB(176, 196, 222))
|
||||
GFX_COLOR(lightyellow, NS_RGB(255, 255, 224))
|
||||
GFX_COLOR(lime, NS_RGB( 0, 255, 0))
|
||||
GFX_COLOR(limegreen, NS_RGB( 50, 205, 50))
|
||||
GFX_COLOR(linen, NS_RGB(250, 240, 230))
|
||||
GFX_COLOR(magenta, NS_RGB(255, 0, 255))
|
||||
GFX_COLOR(maroon, NS_RGB(128, 0, 0))
|
||||
GFX_COLOR(mediumaquamarine, NS_RGB(102, 205, 170))
|
||||
GFX_COLOR(mediumblue, NS_RGB( 0, 0, 205))
|
||||
GFX_COLOR(mediumorchid, NS_RGB(186, 85, 211))
|
||||
GFX_COLOR(mediumpurple, NS_RGB(147, 112, 219))
|
||||
GFX_COLOR(mediumseagreen, NS_RGB( 60, 179, 113))
|
||||
GFX_COLOR(mediumslateblue, NS_RGB(123, 104, 238))
|
||||
GFX_COLOR(mediumspringgreen, NS_RGB( 0, 250, 154))
|
||||
GFX_COLOR(mediumturquoise, NS_RGB( 72, 209, 204))
|
||||
GFX_COLOR(mediumvioletred, NS_RGB(199, 21, 133))
|
||||
GFX_COLOR(midnightblue, NS_RGB( 25, 25, 112))
|
||||
GFX_COLOR(mintcream, NS_RGB(245, 255, 250))
|
||||
GFX_COLOR(mistyrose, NS_RGB(255, 228, 225))
|
||||
GFX_COLOR(moccasin, NS_RGB(255, 228, 181))
|
||||
GFX_COLOR(navajowhite, NS_RGB(255, 222, 173))
|
||||
GFX_COLOR(navy, NS_RGB( 0, 0, 128))
|
||||
GFX_COLOR(oldlace, NS_RGB(253, 245, 230))
|
||||
GFX_COLOR(olive, NS_RGB(128, 128, 0))
|
||||
GFX_COLOR(olivedrab, NS_RGB(107, 142, 35))
|
||||
GFX_COLOR(orange, NS_RGB(255, 165, 0))
|
||||
GFX_COLOR(orangered, NS_RGB(255, 69, 0))
|
||||
GFX_COLOR(orchid, NS_RGB(218, 112, 214))
|
||||
GFX_COLOR(palegoldenrod, NS_RGB(238, 232, 170))
|
||||
GFX_COLOR(palegreen, NS_RGB(152, 251, 152))
|
||||
GFX_COLOR(paleturquoise, NS_RGB(175, 238, 238))
|
||||
GFX_COLOR(palevioletred, NS_RGB(219, 112, 147))
|
||||
GFX_COLOR(papayawhip, NS_RGB(255, 239, 213))
|
||||
GFX_COLOR(peachpuff, NS_RGB(255, 218, 185))
|
||||
GFX_COLOR(peru, NS_RGB(205, 133, 63))
|
||||
GFX_COLOR(pink, NS_RGB(255, 192, 203))
|
||||
GFX_COLOR(plum, NS_RGB(221, 160, 221))
|
||||
GFX_COLOR(powderblue, NS_RGB(176, 224, 230))
|
||||
GFX_COLOR(purple, NS_RGB(128, 0, 128))
|
||||
GFX_COLOR(red, NS_RGB(255, 0, 0))
|
||||
GFX_COLOR(rosybrown, NS_RGB(188, 143, 143))
|
||||
GFX_COLOR(royalblue, NS_RGB( 65, 105, 225))
|
||||
GFX_COLOR(saddlebrown, NS_RGB(139, 69, 19))
|
||||
GFX_COLOR(salmon, NS_RGB(250, 128, 114))
|
||||
GFX_COLOR(sandybrown, NS_RGB(244, 164, 96))
|
||||
GFX_COLOR(seagreen, NS_RGB( 46, 139, 87))
|
||||
GFX_COLOR(seashell, NS_RGB(255, 245, 238))
|
||||
GFX_COLOR(sienna, NS_RGB(160, 82, 45))
|
||||
GFX_COLOR(silver, NS_RGB(192, 192, 192))
|
||||
GFX_COLOR(skyblue, NS_RGB(135, 206, 235))
|
||||
GFX_COLOR(slateblue, NS_RGB(106, 90, 205))
|
||||
GFX_COLOR(slategray, NS_RGB(112, 128, 144))
|
||||
GFX_COLOR(slategrey, NS_RGB(112, 128, 144))
|
||||
GFX_COLOR(snow, NS_RGB(255, 250, 250))
|
||||
GFX_COLOR(springgreen, NS_RGB( 0, 255, 127))
|
||||
GFX_COLOR(steelblue, NS_RGB( 70, 130, 180))
|
||||
GFX_COLOR(tan, NS_RGB(210, 180, 140))
|
||||
GFX_COLOR(teal, NS_RGB( 0, 128, 128))
|
||||
GFX_COLOR(thistle, NS_RGB(216, 191, 216))
|
||||
GFX_COLOR(tomato, NS_RGB(255, 99, 71))
|
||||
GFX_COLOR(turquoise, NS_RGB( 64, 224, 208))
|
||||
GFX_COLOR(violet, NS_RGB(238, 130, 238))
|
||||
GFX_COLOR(wheat, NS_RGB(245, 222, 179))
|
||||
GFX_COLOR(white, NS_RGB(255, 255, 255))
|
||||
GFX_COLOR(whitesmoke, NS_RGB(245, 245, 245))
|
||||
GFX_COLOR(yellow, NS_RGB(255, 255, 0))
|
||||
GFX_COLOR(yellowgreen, NS_RGB(154, 205, 50))
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsColorNames_h___
|
||||
#define nsColorNames_h___
|
||||
|
||||
#include "nsColor.h"
|
||||
|
||||
struct nsStr;
|
||||
class nsAFlatCString;
|
||||
class nsAString;
|
||||
class nsACString;
|
||||
|
||||
/*
|
||||
Declare the enum list using the magic of preprocessing
|
||||
enum values are "eColorName_foo" (where foo is the color name)
|
||||
|
||||
To change the list of colors, see nsColorNameList.h
|
||||
|
||||
*/
|
||||
#define GFX_COLOR(_name, _value) eColorName_##_name,
|
||||
enum nsColorName {
|
||||
eColorName_UNKNOWN = -1,
|
||||
#include "nsColorNameList.h"
|
||||
eColorName_COUNT
|
||||
};
|
||||
#undef GFX_COLOR
|
||||
|
||||
class NS_GFX nsColorNames {
|
||||
public:
|
||||
static void AddRefTable(void);
|
||||
static void ReleaseTable(void);
|
||||
|
||||
// Given a color name, return the color enum value
|
||||
// This only functions provided a valid ref on the table
|
||||
static nsColorName LookupName(const nsAString& aName);
|
||||
static nsColorName LookupName(const nsACString& aName);
|
||||
|
||||
static const nsAFlatCString& GetStringValue(nsColorName aColorName);
|
||||
|
||||
// Color id to rgb value table
|
||||
static const nscolor kColors[];
|
||||
};
|
||||
|
||||
#endif /* nsColorNames_h___ */
|
||||
@@ -1,348 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Stell <bstell@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSCOMPRESSEDCHARMAP_H
|
||||
#define NSCOMPRESSEDCHARMAP_H
|
||||
#include "prtypes.h"
|
||||
|
||||
|
||||
#define ALU_SIZE PR_BITS_PER_LONG
|
||||
//#define ALU_SIZE 16
|
||||
//#define ALU_SIZE 32
|
||||
//#define ALU_SIZE 64
|
||||
#if (ALU_SIZE==32)
|
||||
# define ALU_TYPE PRUint32
|
||||
# define CCMAP_POW2(n) (1L<<(n))
|
||||
# define CCMAP_BITS_PER_ALU_LOG2 5
|
||||
#elif (ALU_SIZE==64)
|
||||
# define ALU_TYPE PRUint64
|
||||
# define CCMAP_POW2(n) (1LL<<(n))
|
||||
# define CCMAP_BITS_PER_ALU_LOG2 6
|
||||
#else
|
||||
# define ALU_TYPE PRUint16
|
||||
# define CCMAP_POW2(n) (1<<(n))
|
||||
# define CCMAP_BITS_PER_ALU_LOG2 4
|
||||
#endif
|
||||
|
||||
|
||||
class nsICharRepresentable;
|
||||
|
||||
extern PRUint16* CreateEmptyCCMap();
|
||||
extern PRUint16* MapToCCMap(PRUint32* aMap);
|
||||
extern PRUint16* MapperToCCMap(nsICharRepresentable *aMapper);
|
||||
extern void FreeCCMap(PRUint16* &aMap);
|
||||
extern PRBool NextNonEmptyCCMapPage(PRUint16 *, PRUint16 *);
|
||||
extern PRBool IsSameCCMap(PRUint16* ccmap1, PRUint16* ccmap2);
|
||||
#ifdef DEBUG
|
||||
void printCCMap(PRUint16* aCCMap);
|
||||
#endif
|
||||
|
||||
|
||||
// surrogate support extension
|
||||
extern PRUint16*
|
||||
MapToCCMapExt(PRUint32* aBmpPlaneMap, PRUint32** aOtherPlaneMaps, PRUint32 aOtherPlaneNum);
|
||||
|
||||
//
|
||||
// nsCompressedCharMap
|
||||
//
|
||||
// A Compressed Char Map (CCMap) saves memory by folding all
|
||||
// the empty portions of the map on top of each other.
|
||||
//
|
||||
// Building a Compressed Char Map (CCMap) is more complex than
|
||||
// accessing it. We use the nsCompressedCharMap object to
|
||||
// build the CCMap. Once nsCompressedCharMap has built the CCMap
|
||||
// we get a copy of the CCMap and discard the nsCompressedCharMap
|
||||
// object. The CCMap is an array of PRUint16 and is accessed by
|
||||
// a macro.
|
||||
//
|
||||
// See "Character Map Compression" below for a discussion of
|
||||
// what the array looks like.
|
||||
|
||||
//
|
||||
// The maximum size a CCMap:
|
||||
// (16 upper pointers) + (16 empty mid pointers) +
|
||||
// (16 empty page) + (16*16 max mid pointers) +
|
||||
// (256*16 max pages) = 4400 PRUint16
|
||||
#define CCMAP_MAX_LEN (16+16+16+256+4096)
|
||||
|
||||
class nsCompressedCharMap {
|
||||
public:
|
||||
nsCompressedCharMap();
|
||||
|
||||
PRUint16* NewCCMap();
|
||||
PRUint16* FillCCMap(PRUint16* aCCMap);
|
||||
PRUint16 GetSize() {return mUsedLen;};
|
||||
void SetChar(PRUint16);
|
||||
void SetChars(PRUint16*);
|
||||
void SetChars(PRUint16, ALU_TYPE*);
|
||||
void SetChars(PRUint32*);
|
||||
|
||||
protected:
|
||||
union {
|
||||
PRUint16 mCCMap[CCMAP_MAX_LEN];
|
||||
ALU_TYPE used_for_align; // do not use; only here to cause
|
||||
// alignment
|
||||
} u;
|
||||
PRUint16 mUsedLen; // in PRUint16
|
||||
PRUint16 mAllOnesPage;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Character Map Compression
|
||||
//
|
||||
// Each font requires its own 8k charmap. On a system with 200
|
||||
// fonts this would take: 200 * 8K = 1600K memory.
|
||||
//
|
||||
// Since most char maps are mostly empty a significant amount
|
||||
// of memory can be saved by not allocating the unused sections.
|
||||
//
|
||||
// If the map has one or more levels of indirection then the
|
||||
// the empty sections of the map can all be folded to a single
|
||||
// common empty element. In this way only the non-empty sections
|
||||
// need space. Because the empty sections actually point to a
|
||||
// common empty section every entry in the map can be valid
|
||||
// without requiring actually allocating space.
|
||||
// Some larger CJK fonts have large sections where every bit
|
||||
// is set. In the same way that the empty sections are folded
|
||||
// onto one "empty page", the sections where all bits are set are
|
||||
// folded on to one "all bits set page" .
|
||||
//
|
||||
// Break up the Unicode range bits 0x0000 - 0xFFFF
|
||||
// into 3 bit ranges:
|
||||
//
|
||||
// upper bits: bit15 - bit12
|
||||
// mid bits: bit11 - bit8
|
||||
// page bits: bit7 - bit0
|
||||
//
|
||||
// within a page, (assumming a 4 byte ALU)
|
||||
// bits 7-5 select one of the 8 longs
|
||||
// bits 4-0 select one of the 32 bits within the long
|
||||
//
|
||||
// There is exactly one upper "pointers" array.
|
||||
//
|
||||
// The upper pointers each point to a mid array. If there are no chars
|
||||
// in an upper pointer's block that pointer points to the empty mid.
|
||||
// Thus all upper pointers are "valid" even if they do not have space
|
||||
// allocated; eg: the accessor macro does not need to test if the
|
||||
// pointer is zero.
|
||||
//
|
||||
// Each mid pointer in the mid array points to a page. If there are no
|
||||
// chars in a mid pointer's page that pointer points to the empty page.
|
||||
// Thus all mid pointers are "valid" even if they do not have space
|
||||
// allocated; eg: the accessor macro does not need to test if the
|
||||
// pointer is zero.
|
||||
//
|
||||
// Since the array will be less than 5K PRUint16 the "pointers" can
|
||||
// be implemented as 2 byte offsets from the base instead of
|
||||
// real pointers.
|
||||
//
|
||||
// the format of the CCMap is
|
||||
// the upper pointers (16 PRUint16)
|
||||
// the empty mid pointers (16 PRUint16)
|
||||
// the empty page (16 PRUint16)
|
||||
// non-empty mid pointers and pages as needed
|
||||
|
||||
// One minor note: for a completely empty map it is actually
|
||||
// possible to fold the upper, empty mid, and empty page
|
||||
// on top of each other and make a map of only 32 bytes.
|
||||
#define CCMAP_EMPTY_SIZE_PER_INT16 16
|
||||
|
||||
// offsets to the empty mid and empty page
|
||||
#define CCMAP_EMPTY_MID CCMAP_NUM_UPPER_POINTERS
|
||||
#define CCMAP_EMPTY_PAGE CCMAP_EMPTY_MID+CCMAP_NUM_MID_POINTERS
|
||||
|
||||
//
|
||||
// Because the table is offset based the code can build the table in a
|
||||
// temp space (max table size on the stack) and then do one alloc of
|
||||
// the actual needed size and simply copy over the data.
|
||||
//
|
||||
|
||||
//
|
||||
// Compressed Char map surrogate extension
|
||||
//
|
||||
// The design goal of surrogate support extension is to keep efficiency
|
||||
// and compatibility of existing compressed charmap operations. Most of
|
||||
// existing operation are untouched. For BMP support, very little memory
|
||||
// overhead (4 bytes) is added. Runtime efficiency of BMP support is
|
||||
// unchanged.
|
||||
//
|
||||
// structure of extended charmap:
|
||||
// ccmap flag 1 PRUint16 , indication if this is extended one or not
|
||||
// bmp ccmap size 1 PRUint16 , the size of BMP ccmap,
|
||||
// BMP ccmap size varies,
|
||||
// plane index 16 PRUint32, use to index ccmap for non-BMP plane
|
||||
// empty ccmap 16 PRUint16, a total empty ccmap
|
||||
// non-BMP ccmaps size varies, other non-empty, non-BMP ccmap
|
||||
//
|
||||
// Changes to basic ccmap
|
||||
// 2 PRUint16 are added in the very beginning. One is used to descript the size
|
||||
// of the ccmap, the other is used as a flag. But these 2 fields are indexed
|
||||
// negatively so that all other operation remain unchanged to keep efficiency.
|
||||
// ccmap memory allocation is moved from nsCompressedCharMap::NewCCMap to
|
||||
// MapToCCMap.
|
||||
//
|
||||
// Extended ccmap
|
||||
// A 16*PRUint32 array was put at the end of basic ccmap, each PRUint32 either
|
||||
// pointed to the empty ccmap or a independent plane ccmap. Directly after this
|
||||
// array is a empty ccmap. All planes that has no character will share this ccmap.
|
||||
// All non-empty plane will have a ccmap.
|
||||
// "MapToCCMapExt" is added to created an extended ccmap, each plane ccmap is
|
||||
// created the same as basic one, but without 2 additional fields.
|
||||
// "HasGlyphExt" is used to access extended ccmap, it first need to locate the
|
||||
// plane ccmap, and then operated the same way as "HasGlyph".
|
||||
//
|
||||
// Compatibility between old and new one
|
||||
// Because extended ccmap include an exactly identical basic ccmap in its head,
|
||||
// basic ccmap operation (HasGlyph) can be applied on extended ccmap without
|
||||
// problem.
|
||||
// Because basic ccmap is now have a flag to indicate if it is a extended one,
|
||||
// Extended ccmap operation (HasGlyphExt) can check the flag before it does
|
||||
// extended ccmap specific operation. So HasGlyphExt can be applied to basic ccmap
|
||||
// too.
|
||||
//
|
||||
|
||||
// Page bits
|
||||
//
|
||||
#define CCMAP_BITS_PER_PAGE_LOG2 8
|
||||
#define CCMAP_BITS_PER_PAGE CCMAP_POW2(CCMAP_BITS_PER_PAGE_LOG2)
|
||||
#define CCMAP_BIT_INDEX(c) ((c) & PR_BITMASK(CCMAP_BITS_PER_ALU_LOG2))
|
||||
#define CCMAP_ALU_INDEX(c) (((c)>>CCMAP_BITS_PER_ALU_LOG2) \
|
||||
& PR_BITMASK(CCMAP_BITS_PER_PAGE_LOG2 - CCMAP_BITS_PER_ALU_LOG2))
|
||||
|
||||
#define CCMAP_PAGE_MASK PR_BITMASK(CCMAP_BITS_PER_PAGE_LOG2)
|
||||
#define CCMAP_NUM_PRUINT16S_PER_PAGE \
|
||||
(CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_PRUINT16)
|
||||
// one bit per char
|
||||
#define CCMAP_NUM_ALUS_PER_PAGE (CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_ALU)
|
||||
#define CCMAP_NUM_UCHARS_PER_PAGE CCMAP_BITS_PER_PAGE
|
||||
|
||||
//
|
||||
// Mid bits
|
||||
//
|
||||
#define CCMAP_BITS_PER_MID_LOG2 4
|
||||
#define CCMAP_MID_INDEX(c) \
|
||||
(((c)>>CCMAP_BITS_PER_PAGE_LOG2) & PR_BITMASK(CCMAP_BITS_PER_MID_LOG2))
|
||||
#define CCMAP_NUM_MID_POINTERS CCMAP_POW2(CCMAP_BITS_PER_MID_LOG2)
|
||||
#define CCMAP_NUM_UCHARS_PER_MID \
|
||||
CCMAP_POW2(CCMAP_BITS_PER_MID_LOG2+CCMAP_BITS_PER_PAGE_LOG2)
|
||||
|
||||
//
|
||||
// Upper bits
|
||||
//
|
||||
#define CCMAP_BITS_PER_UPPER_LOG2 4
|
||||
#define CCMAP_UPPER_INDEX(c) \
|
||||
(((c)>>(CCMAP_BITS_PER_MID_LOG2+CCMAP_BITS_PER_PAGE_LOG2)) \
|
||||
& PR_BITMASK(CCMAP_BITS_PER_UPPER_LOG2))
|
||||
#define CCMAP_NUM_UPPER_POINTERS CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2)
|
||||
|
||||
//
|
||||
// Misc
|
||||
//
|
||||
#define CCMAP_BITS_PER_PRUINT16_LOG2 4
|
||||
#define CCMAP_BITS_PER_PRUINT32_LOG2 5
|
||||
|
||||
#define CCMAP_BITS_PER_PRUINT16 CCMAP_POW2(CCMAP_BITS_PER_PRUINT16_LOG2)
|
||||
#define CCMAP_BITS_PER_PRUINT32 CCMAP_POW2(CCMAP_BITS_PER_PRUINT32_LOG2)
|
||||
#define CCMAP_BITS_PER_ALU CCMAP_POW2(CCMAP_BITS_PER_ALU_LOG2)
|
||||
|
||||
#define CCMAP_ALUS_PER_PRUINT32 (CCMAP_BITS_PER_PRUINT32/CCMAP_BITS_PER_ALU)
|
||||
#define CCMAP_PRUINT32S_PER_ALU (CCMAP_BITS_PER_ALU/CCMAP_BITS_PER_PRUINT32)
|
||||
#define CCMAP_PRUINT32S_PER_PAGE (CCMAP_BITS_PER_PAGE/CCMAP_BITS_PER_PRUINT32)
|
||||
|
||||
#define CCMAP_ALU_MASK PR_BITMASK(CCMAP_BITS_PER_ALU)
|
||||
#define CCMAP_ALUS_PER_PAGE CCMAP_POW2(CCMAP_BITS_PER_PAGE_LOG2 \
|
||||
- CCMAP_BITS_PER_ALU_LOG2)
|
||||
#define NUM_UNICODE_CHARS CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2 \
|
||||
+CCMAP_BITS_PER_MID_LOG2 \
|
||||
+CCMAP_BITS_PER_PAGE_LOG2)
|
||||
#define CCMAP_TOTAL_PAGES CCMAP_POW2(CCMAP_BITS_PER_UPPER_LOG2 \
|
||||
+CCMAP_BITS_PER_MID_LOG2)
|
||||
|
||||
#define CCMAP_BEGIN_AT_START_OF_MAP 0xFFFF
|
||||
|
||||
//
|
||||
// Finally, build up the macro to test the bit for a given char
|
||||
//
|
||||
|
||||
// offset from base to mid array
|
||||
#define CCMAP_TO_MID(m,c) ((m)[CCMAP_UPPER_INDEX(c)])
|
||||
|
||||
// offset from base to page
|
||||
#define CCMAP_TO_PAGE(m,c) ((m)[CCMAP_TO_MID((m),(c)) + CCMAP_MID_INDEX(c)])
|
||||
|
||||
// offset from base to alu
|
||||
#define CCMAP_TO_ALU(m,c) \
|
||||
(*((ALU_TYPE*)(&((m)[CCMAP_TO_PAGE((m),(c))])) + CCMAP_ALU_INDEX(c)))
|
||||
|
||||
// test the bit
|
||||
#define CCMAP_HAS_CHAR(m,c) (((CCMAP_TO_ALU(m,c))>>CCMAP_BIT_INDEX(c)) & 1)
|
||||
|
||||
// unset the bit
|
||||
#define CCMAP_UNSET_CHAR(m,c) (CCMAP_TO_ALU(m,c) &= ~(CCMAP_POW2(CCMAP_BIT_INDEX(c))))
|
||||
|
||||
#define CCMAP_SIZE(m) (*((m)-1))
|
||||
#define CCMAP_FLAG(m) (*((m)-2))
|
||||
#define CCMAP_EXTRA (sizeof(ALU_TYPE)/sizeof(PRUint16)>2? sizeof(ALU_TYPE)/sizeof(PRUint16): 2)
|
||||
#define CCMAP_SURROGATE_FLAG 0X0001
|
||||
#define CCMAP_NONE_FLAG 0x0000
|
||||
|
||||
// non-bmp unicode support extension
|
||||
#define EXTENDED_UNICODE_PLANES 16
|
||||
|
||||
// get plane number from ccmap, bmp excluded, so plane 1's number is 0.
|
||||
#define CCMAP_PLANE_FROM_SURROGATE(h) ((((PRUint16)(h) - (PRUint16)0xd800) >> 6) + 1)
|
||||
|
||||
// same as above, but get plane number from a ucs4 char
|
||||
#define CCMAP_PLANE(u) ((((PRUint32)(u))>>16))
|
||||
|
||||
// scalar value inside the plane
|
||||
#define CCMAP_INPLANE_OFFSET(h, l) (((((PRUint16)(h) - (PRUint16)0xd800) & 0x3f) << 10) + ((PRUint16)(l) - (PRUint16)0xdc00))
|
||||
|
||||
// get ccmap for that plane
|
||||
#define CCMAP_FOR_PLANE_EXT(m, i) ((m) + ((PRUint32*)((m) + CCMAP_SIZE(m)))[(i)-1])
|
||||
|
||||
// test the bit for surrogate pair
|
||||
#define CCMAP_HAS_CHAR_EXT2(m, h, l) (CCMAP_FLAG(m)&CCMAP_SURROGATE_FLAG && \
|
||||
CCMAP_HAS_CHAR(CCMAP_FOR_PLANE_EXT((m), CCMAP_PLANE_FROM_SURROGATE(h)), CCMAP_INPLANE_OFFSET(h, l)))
|
||||
// test the bit for a character in UCS4
|
||||
#define CCMAP_HAS_CHAR_EXT(m, ucs4) (!((ucs4)&0xffff0000) && CCMAP_HAS_CHAR(m, (PRUnichar)(ucs4)) || \
|
||||
CCMAP_FLAG(m)&CCMAP_SURROGATE_FLAG && CCMAP_HAS_CHAR(CCMAP_FOR_PLANE_EXT((m), CCMAP_PLANE(ucs4)), (ucs4)&0xffff))
|
||||
|
||||
#endif // NSCOMPRESSEDCHARMAP_H
|
||||
@@ -1,58 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSCOORD_H
|
||||
#define NSCOORD_H
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
/*
|
||||
* Basic type used for the geometry classes. By making it a typedef we can
|
||||
* easily change it in the future.
|
||||
*
|
||||
* All coordinates are maintained as signed 32-bit integers in the twips
|
||||
* coordinate space. A twip is 1/20th of a point, and there are 72 points per
|
||||
* inch.
|
||||
*
|
||||
* Twips are used because they are a device-independent unit of measure. See
|
||||
* header file nsUnitConversion.h for many useful macros to convert between
|
||||
* different units of measure.
|
||||
*/
|
||||
typedef PRInt32 nscoord;
|
||||
|
||||
#endif /* NSCOORD_H */
|
||||
@@ -1,184 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDeviceContext_h___
|
||||
#define nsDeviceContext_h___
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsIImageRequest;
|
||||
class nsHashtable;
|
||||
|
||||
class nsFontCache
|
||||
{
|
||||
public:
|
||||
nsFontCache();
|
||||
virtual ~nsFontCache();
|
||||
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext);
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext) const;
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIFontMetrics *&aMetrics);
|
||||
|
||||
nsresult FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
|
||||
nsresult Compact();
|
||||
nsresult Flush();
|
||||
/* printer device context classes may create their own
|
||||
* subclasses of nsFontCache (and override this method) and override
|
||||
* DeviceContextImpl::CreateFontCache (see bug 81311).
|
||||
*/
|
||||
NS_IMETHOD CreateFontMetricsInstance(nsIFontMetrics** fm);
|
||||
|
||||
protected:
|
||||
nsVoidArray mFontMetrics;
|
||||
nsIDeviceContext *mContext; // we do not addref this since
|
||||
// ownership is implied. MMP.
|
||||
};
|
||||
|
||||
class NS_GFX DeviceContextImpl : public nsIDeviceContext,
|
||||
public nsIObserver,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
DeviceContextImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext){return NS_ERROR_NOT_IMPLEMENTED;}
|
||||
|
||||
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow);
|
||||
|
||||
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const;
|
||||
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const;
|
||||
|
||||
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits);
|
||||
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits);
|
||||
|
||||
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const;
|
||||
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const;
|
||||
|
||||
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const;
|
||||
NS_IMETHOD SetCanonicalPixelScale(float aScale);
|
||||
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIFontMetrics*& aMetrics);
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics);
|
||||
|
||||
NS_IMETHOD SetZoom(float aZoom);
|
||||
NS_IMETHOD GetZoom(float &aZoom) const;
|
||||
|
||||
NS_IMETHOD SetTextZoom(float aTextZoom);
|
||||
NS_IMETHOD GetTextZoom(float &aTextZoom) const;
|
||||
|
||||
NS_IMETHOD GetGamma(float &aGamma);
|
||||
NS_IMETHOD SetGamma(float aGamma);
|
||||
|
||||
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable);
|
||||
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased);
|
||||
|
||||
NS_IMETHOD CreateFontCache();
|
||||
NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
|
||||
NS_IMETHOD FlushFontCache(void);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC);
|
||||
NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) { *aAltDC = mAltDC.get(); NS_IF_ADDREF(*aAltDC); return NS_OK;}
|
||||
NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn);
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual ~DeviceContextImpl();
|
||||
|
||||
void CommonInit(void);
|
||||
void SetGammaTable(PRUint8 * aTable, float aCurrentGamma, float aNewGamma);
|
||||
nsresult CreateIconILGroupContext();
|
||||
virtual nsresult CreateFontAliasTable();
|
||||
nsresult AliasFont(const nsString& aFont,
|
||||
const nsString& aAlias, const nsString& aAltAlias,
|
||||
PRBool aForceAlias);
|
||||
void GetLocaleLangGroup(void);
|
||||
|
||||
float mTwipsToPixels;
|
||||
float mPixelsToTwips;
|
||||
float mAppUnitsToDevUnits;
|
||||
float mDevUnitsToAppUnits;
|
||||
nsFontCache *mFontCache;
|
||||
nsCOMPtr<nsIAtom> mLocaleLangGroup; // XXX temp fix for performance bug - erik
|
||||
float mZoom;
|
||||
float mTextZoom;
|
||||
float mGammaValue;
|
||||
PRUint8 *mGammaTable;
|
||||
nsHashtable* mFontAliasTable;
|
||||
float mCPixelScale;
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
nsCOMPtr<nsIDeviceContext> mAltDC;
|
||||
PRUint8 mUseAltDC;
|
||||
#endif
|
||||
|
||||
public:
|
||||
nsNativeWidget mWidget;
|
||||
#ifdef NS_DEBUG
|
||||
PRBool mInitialized;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContext_h___ */
|
||||
@@ -1,143 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsFont_h___
|
||||
#define nsFont_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// XXX we need a method to enumerate all of the possible fonts on the
|
||||
// system across family, weight, style, size, etc. But not here!
|
||||
|
||||
// Enumerator callback function. Return PR_FALSE to stop
|
||||
typedef PRBool (*nsFontFamilyEnumFunc)(const nsString& aFamily, PRBool aGeneric, void *aData);
|
||||
|
||||
// IDs for generic fonts
|
||||
// NOTE: 0, 1 are reserved for the special IDs of the default variable
|
||||
// and fixed fonts in the presentation context, see nsIPresContext.h
|
||||
const PRUint8 kGenericFont_NONE = 0x00;
|
||||
// Special
|
||||
const PRUint8 kGenericFont_moz_variable = 0x00; // for the default variable width font
|
||||
const PRUint8 kGenericFont_moz_fixed = 0x01; // our special "use the user's fixed font"
|
||||
// CSS
|
||||
const PRUint8 kGenericFont_serif = 0x02;
|
||||
const PRUint8 kGenericFont_sans_serif = 0x04;
|
||||
const PRUint8 kGenericFont_monospace = 0x08;
|
||||
const PRUint8 kGenericFont_cursive = 0x10;
|
||||
const PRUint8 kGenericFont_fantasy = 0x20;
|
||||
|
||||
// Font structure.
|
||||
struct NS_GFX nsFont {
|
||||
// The family name of the font
|
||||
nsString name;
|
||||
|
||||
// The style of font (normal, italic, oblique)
|
||||
PRUint8 style;
|
||||
|
||||
// The variant of the font (normal, small-caps)
|
||||
PRUint8 variant;
|
||||
|
||||
// The weight of the font (0-999)
|
||||
PRUint16 weight;
|
||||
|
||||
// The decorations on the font (underline, overline,
|
||||
// line-through). The decorations can be binary or'd together.
|
||||
PRUint8 decorations;
|
||||
|
||||
// The logical size of the font, in nscoord units
|
||||
nscoord size;
|
||||
|
||||
// The aspect-value (ie., the ratio actualsize:actualxheight) that any
|
||||
// actual physical font created from this font structure must have when
|
||||
// rendering or measuring a string. A value of 0 means no adjustment
|
||||
// needs to be done.
|
||||
float sizeAdjust;
|
||||
|
||||
// Initialize the font struct with an iso-latin1 name
|
||||
nsFont(const char* aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust=0.0f);
|
||||
|
||||
// Initialize the font struct with a (potentially) unicode name
|
||||
nsFont(const nsString& aName, PRUint8 aStyle, PRUint8 aVariant,
|
||||
PRUint16 aWeight, PRUint8 aDecoration, nscoord aSize,
|
||||
float aSizeAdjust=0.0f);
|
||||
|
||||
// Make a copy of the given font
|
||||
nsFont(const nsFont& aFont);
|
||||
|
||||
nsFont();
|
||||
~nsFont();
|
||||
|
||||
PRBool operator==(const nsFont& aOther) const {
|
||||
return Equals(aOther);
|
||||
}
|
||||
|
||||
PRBool Equals(const nsFont& aOther) const ;
|
||||
|
||||
nsFont& operator=(const nsFont& aOther);
|
||||
|
||||
// Utility method to interpret name string
|
||||
// enumerates all families specified by this font only
|
||||
// returns PR_TRUE if completed, PR_FALSE if stopped
|
||||
// enclosing quotes will be removed, and whitespace compressed (as needed)
|
||||
PRBool EnumerateFamilies(nsFontFamilyEnumFunc aFunc, void* aData) const;
|
||||
void GetFirstFamily(nsString& aFamily) const;
|
||||
|
||||
// Utility method to return the ID of a generic font
|
||||
static void GetGenericID(const nsString& aGeneric, PRUint8* aID);
|
||||
};
|
||||
|
||||
#define NS_FONT_STYLE_NORMAL 0
|
||||
#define NS_FONT_STYLE_ITALIC 1
|
||||
#define NS_FONT_STYLE_OBLIQUE 2
|
||||
|
||||
#define NS_FONT_VARIANT_NORMAL 0
|
||||
#define NS_FONT_VARIANT_SMALL_CAPS 1
|
||||
|
||||
#define NS_FONT_DECORATION_NONE 0x0
|
||||
#define NS_FONT_DECORATION_UNDERLINE 0x1
|
||||
#define NS_FONT_DECORATION_OVERLINE 0x2
|
||||
#define NS_FONT_DECORATION_LINE_THROUGH 0x4
|
||||
|
||||
#define NS_FONT_WEIGHT_NORMAL 400
|
||||
#define NS_FONT_WEIGHT_BOLD 700
|
||||
|
||||
#endif /* nsFont_h___ */
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsGfxCIID_h__
|
||||
#define nsGfxCIID_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#define NS_IMAGE_CID \
|
||||
{ 0x6049b260, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_RENDERING_CONTEXT_CID \
|
||||
{ 0x6049b261, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_DEVICE_CONTEXT_CID \
|
||||
{ 0x6049b262, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_FONT_METRICS_CID \
|
||||
{ 0x6049b263, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_FONT_ENUMERATOR_CID \
|
||||
{ 0xa6cf9115, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
|
||||
|
||||
#define NS_FONTLIST_CID \
|
||||
{ 0x6a8c0dd4, 0x1dd2, 0x11b2, \
|
||||
{ 0x9a, 0x8f, 0xf8, 0x2f, 0x9d, 0xf2, 0x5b, 0x07 } }
|
||||
|
||||
#define NS_REGION_CID \
|
||||
{ 0xe12752f0, 0xee9a, 0x11d1, \
|
||||
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_SCRIPTABLE_REGION_CID \
|
||||
{ 0xda5b130a, 0x1dd1, 0x11b2, \
|
||||
{ 0xad, 0x47, 0xf4, 0x55, 0xb1, 0x81, 0x4a, 0x78 } }
|
||||
|
||||
#define NS_BLENDER_CID \
|
||||
{ 0x6049b264, 0xc1e6, 0x11d1, \
|
||||
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_DEVICE_CONTEXT_SPEC_CID \
|
||||
{ 0xd7193600, 0x78e0, 0x11d2, \
|
||||
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_DEVICE_CONTEXT_SPEC_FACTORY_CID \
|
||||
{ 0xec5bebb0, 0x7b51, 0x11d2, \
|
||||
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_DRAWING_SURFACE_CID \
|
||||
{ 0x199c7040, 0xcab0, 0x11d2, \
|
||||
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
#define NS_SCREENMANAGER_CID \
|
||||
{ 0xc401eb80, 0xf9ea, 0x11d3, \
|
||||
{ 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } }
|
||||
|
||||
#define NS_PRINTOPTIONS_CID \
|
||||
{ 0x30a3b080, 0x4867, 0x11d4, \
|
||||
{ 0xa8, 0x56, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } }
|
||||
|
||||
#define NS_PRINTER_ENUMERATOR_CID \
|
||||
{ 0xa6cf9129, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
|
||||
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIBlender_h___
|
||||
#define nsIBlender_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
// IID for the nsIBlender interface
|
||||
#define NS_IBLENDER_IID \
|
||||
{ 0xbdb4b5b0, 0xf0db, 0x11d1, \
|
||||
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Blender interface
|
||||
class nsIBlender : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IBLENDER_IID)
|
||||
|
||||
/**
|
||||
* Initialize the Blender
|
||||
* @update dc 11/4/98
|
||||
* @param aContext is where the blender can get info about the device its blending on
|
||||
* @result The result of the initialization, NS_OK if no errors
|
||||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext *aContext) = 0;
|
||||
|
||||
/**
|
||||
* NOTE: if we can make this static, that would be great. I don't think we can.
|
||||
* Blend source and destination nsDrawingSurfaces. Both drawing surfaces
|
||||
* will have bitmaps associated with them.
|
||||
* @param aSX x offset into source drawing surface of blend area
|
||||
* @param aSY y offset into source drawing surface of blend area
|
||||
* @param aWidth width of blend area
|
||||
* @param aHeight width of blend area
|
||||
* @param aSrc source for the blending
|
||||
* @param aDest destination for blending
|
||||
* @param aDX x offset into destination drawing surface of blend area
|
||||
* @param aDY y offset into destination drawing surface of blend area
|
||||
* @param aSrcOpacity 0.0f -> 1.0f opacity value of source area. 1.0f indicates
|
||||
* complete opacity.
|
||||
* @param aSecondSrc an optional second source drawing surface which is used in
|
||||
* conjunction with the background color parameters to determine
|
||||
* which pixels to blend
|
||||
* @param aSrcBackColor color of pixels in aSrc that should be
|
||||
* considered "background" color
|
||||
* @param aSecondSrcBackColor color of pixels in aSrc that should be
|
||||
* considered "background" color
|
||||
*/
|
||||
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight,nsDrawingSurface aSrc,
|
||||
nsDrawingSurface aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsDrawingSurface aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
|
||||
|
||||
NS_IMETHOD Blend(PRInt32 aSX, PRInt32 aSY, PRInt32 aWidth, PRInt32 aHeight, nsIRenderingContext *aSrc,
|
||||
nsIRenderingContext *aDest, PRInt32 aDX, PRInt32 aDY, float aSrcOpacity,
|
||||
nsIRenderingContext *aSecondSrc = nsnull, nscolor aSrcBackColor = NS_RGB(0, 0, 0),
|
||||
nscolor aSecondSrcBackColor = NS_RGB(0, 0, 0)) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,513 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDeviceContext_h___
|
||||
#define nsIDeviceContext_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
class nsIView;
|
||||
class nsIFontMetrics;
|
||||
class nsIWidget;
|
||||
class nsIDeviceContextSpec;
|
||||
class nsIAtom;
|
||||
|
||||
struct nsFont;
|
||||
struct nsColor;
|
||||
|
||||
//a cross platform way of specifying a native device context
|
||||
typedef void * nsNativeDeviceContext;
|
||||
|
||||
/* error codes for printer device contexts */
|
||||
#define NS_ERROR_GFX_PRINTER_BASE (1) /* adjustable :-) */
|
||||
/* Unix: print command (lp/lpr) not found */
|
||||
#define NS_ERROR_GFX_PRINTER_CMD_NOT_FOUND \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+1)
|
||||
/* Unix: print command returned an error */
|
||||
#define NS_ERROR_GFX_PRINTER_CMD_FAILURE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+2)
|
||||
/* no printer available (e.g. cannot find _any_ printer) */
|
||||
#define NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+3)
|
||||
/* _specified_ (by name) printer not found */
|
||||
#define NS_ERROR_GFX_PRINTER_NAME_NOT_FOUND \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+4)
|
||||
/* access to printer denied */
|
||||
#define NS_ERROR_GFX_PRINTER_ACCESS_DENIED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+5)
|
||||
/* invalid printer attribute (for example: unsupported paper size etc.) */
|
||||
#define NS_ERROR_GFX_PRINTER_INVALID_ATTRIBUTE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+6)
|
||||
/* printer not "ready" (offline ?) */
|
||||
#define NS_ERROR_GFX_PRINTER_PRINTER_NOT_READY \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+8)
|
||||
/* printer out of paper */
|
||||
#define NS_ERROR_GFX_PRINTER_OUT_OF_PAPER \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+9)
|
||||
/* generic printer I/O error */
|
||||
#define NS_ERROR_GFX_PRINTER_PRINTER_IO_ERROR \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+10)
|
||||
/* print-to-file: could not open output file */
|
||||
#define NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+11)
|
||||
/* print-to-file: I/O error while printing to file */
|
||||
#define NS_ERROR_GFX_PRINTER_FILE_IO_ERROR \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+12)
|
||||
/* print preview: needs at least one printer */
|
||||
#define NS_ERROR_GFX_PRINTER_PRINTPREVIEW \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+13)
|
||||
/* print: starting document */
|
||||
#define NS_ERROR_GFX_PRINTER_STARTDOC \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+14)
|
||||
/* print: ending document */
|
||||
#define NS_ERROR_GFX_PRINTER_ENDDOC \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+15)
|
||||
/* print: starting page */
|
||||
#define NS_ERROR_GFX_PRINTER_STARTPAGE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+16)
|
||||
/* print: ending page */
|
||||
#define NS_ERROR_GFX_PRINTER_ENDPAGE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+17)
|
||||
/* print: print while in print preview */
|
||||
#define NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+18)
|
||||
/* requested page size not supported by printer */
|
||||
#define NS_ERROR_GFX_PRINTER_PAPER_SIZE_NOT_SUPPORTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+19)
|
||||
/* requested page orientation not supported */
|
||||
#define NS_ERROR_GFX_PRINTER_ORIENTATION_NOT_SUPPORTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+20)
|
||||
/* requested colorspace not supported (like printing "color" on a "grayscale"-only printer) */
|
||||
#define NS_ERROR_GFX_PRINTER_COLORSPACE_NOT_SUPPORTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+21)
|
||||
/* too many copies requested */
|
||||
#define NS_ERROR_GFX_PRINTER_TOO_MANY_COPIES \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+22)
|
||||
|
||||
|
||||
/**
|
||||
* Conts need for Print Preview
|
||||
*/
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
const PRUint8 kUseAltDCFor_NONE = 0x00; // Do not use the AltDC for anything
|
||||
const PRUint8 kUseAltDCFor_FONTMETRICS = 0x01; // Use it for only getting the font metrics
|
||||
const PRUint8 kUseAltDCFor_CREATERC_REFLOW = 0x02; // Use when creating RenderingContexts for Reflow
|
||||
const PRUint8 kUseAltDCFor_CREATERC_PAINT = 0x04; // Use when creating RenderingContexts for Painting
|
||||
const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Surface Dimensions
|
||||
#endif
|
||||
|
||||
#define NS_IDEVICE_CONTEXT_IID \
|
||||
{ 0x5931c580, 0xb917, 0x11d1, \
|
||||
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
//a cross platform way of specifying a native palette handle
|
||||
typedef void * nsPalette;
|
||||
|
||||
//structure used to return information about a device's palette capabilities
|
||||
struct nsPaletteInfo {
|
||||
PRPackedBool isPaletteDevice;
|
||||
PRUint16 sizePalette; // number of entries in the palette
|
||||
PRUint16 numReserved; // number of reserved palette entries
|
||||
nsPalette palette; // native palette handle
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
eSystemFont_Caption, // css2
|
||||
eSystemFont_Icon,
|
||||
eSystemFont_Menu,
|
||||
eSystemFont_MessageBox,
|
||||
eSystemFont_SmallCaption,
|
||||
eSystemFont_StatusBar,
|
||||
|
||||
eSystemFont_Window, // css3
|
||||
eSystemFont_Document,
|
||||
eSystemFont_Workspace,
|
||||
eSystemFont_Desktop,
|
||||
eSystemFont_Info,
|
||||
eSystemFont_Dialog,
|
||||
eSystemFont_Button,
|
||||
eSystemFont_PullDownMenu,
|
||||
eSystemFont_List,
|
||||
eSystemFont_Field,
|
||||
|
||||
eSystemFont_Tooltips, // moz
|
||||
eSystemFont_Widget,
|
||||
eSystemFont_Theme
|
||||
} nsSystemFontID;
|
||||
|
||||
class nsIDeviceContext : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_IID)
|
||||
|
||||
/**
|
||||
* Initialize the device context from a widget
|
||||
* @param aWidget a native widget to initialize the device context from
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsNativeWidget aWidget) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIView
|
||||
* @param aView view to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it from an nsIWidget
|
||||
* @param aWidget widget to initialize context from
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Create a rendering context and initialize it. This API should *only* be called
|
||||
* on device contexts whose SupportsNativeWidgets() method return PR_FALSE.
|
||||
* @param aContext out parameter for new rendering context
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* Initialize a rendering context from a widget. This method is only for use
|
||||
* when a rendering context was obtained directly from a factory rather than
|
||||
* through one of the Create* methods above.
|
||||
* @param aContext rendering context to initialize
|
||||
* @param aWindow widget to initialize context from
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow) = 0;
|
||||
|
||||
/**
|
||||
* Query the device to see if it supports native widgets. If not, then
|
||||
* nsIWidget->Create() calls should be avoided.
|
||||
* @param aSupportsWidgets out paramater. If PR_TRUE, then native widgets
|
||||
* can be created.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets) = 0;
|
||||
|
||||
/**
|
||||
* Obtain the size of a device unit relative to a Twip. A twip is 1/20 of
|
||||
* a point (which is 1/72 of an inch).
|
||||
* @param aDevUnitsToTwips out parameter for conversion value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetDevUnitsToTwips(float &aDevUnitsToTwips) const = 0;
|
||||
|
||||
/**
|
||||
* Obtain the size of a Twip relative to a device unit.
|
||||
* @param aTwipsToDevUnits out parameter for conversion value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetTwipsToDevUnits(float &aTwipsToDevUnits) const = 0;
|
||||
|
||||
/**
|
||||
* Set the scale factor to convert units used by the application
|
||||
* to device units. Typically, an application will query the device
|
||||
* for twips to device units scale and then set the scale
|
||||
* to convert from whatever unit the application wants to use
|
||||
* to device units. From that point on, all other parts of the
|
||||
* app can use the Get* methods below to figure out how
|
||||
* to convert device units <-> app units.
|
||||
* @param aAppUnits scale value to convert from application defined
|
||||
* units to device units.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD SetAppUnitsToDevUnits(float aAppUnits) = 0;
|
||||
|
||||
/**
|
||||
* Set the scale factor to convert device units to units
|
||||
* used by the application. This should generally be
|
||||
* 1.0f / the value passed into SetAppUnitsToDevUnits().
|
||||
* @param aDevUnits scale value to convert from device units to
|
||||
* application defined units
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD SetDevUnitsToAppUnits(float aDevUnits) = 0;
|
||||
|
||||
/**
|
||||
* Get the scale factor to convert from application defined
|
||||
* units to device units.
|
||||
* @param aAppUnits out paramater for scale value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetAppUnitsToDevUnits(float &aAppUnits) const = 0;
|
||||
|
||||
/**
|
||||
* Get the scale factor to convert from device units to
|
||||
* application defined units.
|
||||
* @param aDevUnits out paramater for scale value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetDevUnitsToAppUnits(float &aDevUnits) const = 0;
|
||||
|
||||
/**
|
||||
* Get the value used to scale a "standard" pixel to a pixel
|
||||
* of the same physical size for this device. a standard pixel
|
||||
* is defined as a pixel on display 0. this is used to make
|
||||
* sure that entities defined in pixel dimensions maintain a
|
||||
* constant relative size when displayed from one output
|
||||
* device to another.
|
||||
* @param aScale out parameter for scale value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetCanonicalPixelScale(float &aScale) const = 0;
|
||||
|
||||
/**
|
||||
* Get the value used to scale a "standard" pixel to a pixel
|
||||
* of the same physical size for this device. a standard pixel
|
||||
* is defined as a pixel on display 0. this is used to make
|
||||
* sure that entities defined in pixel dimensions maintain a
|
||||
* constant relative size when displayed from one output
|
||||
* device to another.
|
||||
* @param aScale in parameter for scale value
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD SetCanonicalPixelScale(float aScale) = 0;
|
||||
|
||||
/**
|
||||
* Get the width of a vertical scroll bar and the height
|
||||
* of a horizontal scrollbar in application units.
|
||||
* @param aWidth out parameter for width
|
||||
* @param aHeight out parameter for height
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const = 0;
|
||||
|
||||
/**
|
||||
* Fill in an nsFont based on the ID of a system font. This function
|
||||
* may or may not fill in the size, so the size should be set to a
|
||||
* reasonable default before calling.
|
||||
*
|
||||
* @param aID The system font ID.
|
||||
* @param aInfo The font structure to be filled in.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const = 0;
|
||||
|
||||
/**
|
||||
* Get the nsIFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aLangGroup the language group of the document
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIFontMetrics*& aMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Get the nsIFontMetrics that describe the properties of
|
||||
* an nsFont.
|
||||
* @param aFont font description to obtain metrics for
|
||||
* @param aMetrics out parameter for font metrics
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics) = 0;
|
||||
|
||||
//get and set the document zoom value used for display-time
|
||||
//scaling. default is 1.0 (no zoom)
|
||||
NS_IMETHOD SetZoom(float aZoom) = 0;
|
||||
NS_IMETHOD GetZoom(float &aZoom) const = 0;
|
||||
|
||||
//get and set the text zoom value used for display-time
|
||||
//scaling. default is 1.0 (no zoom)
|
||||
NS_IMETHOD SetTextZoom(float aTextZoom) = 0;
|
||||
NS_IMETHOD GetTextZoom(float &aTextZoom) const = 0;
|
||||
|
||||
//get a low level drawing surface for rendering. the rendering context
|
||||
//that is passed in is used to create the drawing surface if there isn't
|
||||
//already one in the device context. the drawing surface is then cached
|
||||
//in the device context for re-use.
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface) = 0;
|
||||
|
||||
//functions for handling gamma correction of output device
|
||||
NS_IMETHOD GetGamma(float &aGamms) = 0;
|
||||
NS_IMETHOD SetGamma(float aGamma) = 0;
|
||||
|
||||
//XXX the return from this really needs to be ref counted somehow. MMP
|
||||
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable) = 0;
|
||||
|
||||
/**
|
||||
* Check to see if a particular named font exists.
|
||||
* @param aFontName character string of font face name
|
||||
* @return NS_OK if font is available, else font is unavailable
|
||||
*/
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFaceName) = 0;
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName) = 0;
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
PRBool& aAliased) = 0;
|
||||
|
||||
/**
|
||||
* Notification when a font metrics instance created for this device is
|
||||
* about to be deleted
|
||||
*/
|
||||
NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics) = 0;
|
||||
|
||||
/**
|
||||
* Attempt to free up resoruces by flushing out any fonts no longer
|
||||
* referenced by anything other than the font cache itself.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD FlushFontCache(void) = 0;
|
||||
|
||||
/**
|
||||
* Return the bit depth of the device.
|
||||
*/
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
|
||||
|
||||
/**
|
||||
* Returns information about the device's palette capabilities.
|
||||
*/
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo) = 0;
|
||||
|
||||
/**
|
||||
* Returns Platform specific pixel value for an RGB value
|
||||
*/
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the displayable area of the output device
|
||||
* in app units.
|
||||
* @param aWidth out parameter for width
|
||||
* @param aHeight out parameter for height
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app units.
|
||||
* This corresponds on a screen device, for instance, to the entire screen.
|
||||
* @param aRect out parameter for full rect. Position (x,y) will be (0,0) or
|
||||
* relative to the primary monitor if this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetRect ( nsRect &aRect ) = 0;
|
||||
|
||||
/**
|
||||
* Get the size of the content area of the output device in app units.
|
||||
* This corresponds on a screen device, for instance, to the area reported
|
||||
* by GetDeviceSurfaceDimensions, minus the taskbar (Windows) or menubar
|
||||
* (Macintosh).
|
||||
* @param aRect out parameter for client rect. Position (x,y) will be (0,0)
|
||||
* adjusted for any upper/left non-client space if present or
|
||||
* relative to the primary monitor if this is not the primary.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetClientRect(nsRect &aRect) = 0;
|
||||
|
||||
/**
|
||||
* Returns a new nsIDeviceContext suitable for the device context
|
||||
* specification passed in.
|
||||
* @param aDevice a device context specification. this is a platform
|
||||
* specific structure that only a platform specific device
|
||||
* context can interpret.
|
||||
* @param aContext out parameter for new device context. nsnull on
|
||||
* failure to create new device context.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext) = 0;
|
||||
|
||||
//XXX need to work out re-entrancy issues for these APIs... MMP
|
||||
/**
|
||||
* Inform the output device that output of a document is beginning
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* EndDocument().
|
||||
* XXX needs to take parameters so that feedback can be given to the
|
||||
* app regarding pagination progress and aborting print operations?
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is ending.
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginDocument()
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD EndDocument(void) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a page is beginning
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* EndPage() and within a BeginDocument()/EndDocument() pair.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginPage(void) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a page is ending
|
||||
* Used for print related device contexts. Must be matched 1:1 with
|
||||
* BeginPage() and within a BeginDocument()/EndDocument() pair.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD EndPage(void) = 0;
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
/**
|
||||
* Set an Alternative Device Context where some of the calls
|
||||
* are deferred to it
|
||||
*/
|
||||
NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC) = 0;
|
||||
|
||||
/**
|
||||
* Get the Alternate Device Context
|
||||
*/
|
||||
NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) = 0;
|
||||
|
||||
/**
|
||||
* Turn on/off which types of information is retrived
|
||||
* via the alt device context
|
||||
*/
|
||||
NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn) = 0;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIDeviceContext_h___ */
|
||||
@@ -1,54 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDeviceContextSpec_h___
|
||||
#define nsIDeviceContextSpec_h___
|
||||
|
||||
#include "nsIDeviceContext.h"
|
||||
|
||||
#define NS_IDEVICE_CONTEXT_SPEC_IID \
|
||||
{ 0x9951f910, 0x78d7, 0x11d2, \
|
||||
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
class nsIDeviceContextSpec : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,87 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDeviceContextSpecFactory_h___
|
||||
#define nsIDeviceContextSpecFactory_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIDeviceContextSpec;
|
||||
class nsIWidget;
|
||||
class nsIPrintSettings;
|
||||
|
||||
#define NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID \
|
||||
{ 0xf6669570, 0x7b3d, 0x11d2, \
|
||||
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
class nsIDeviceContextSpecFactory : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID)
|
||||
/**
|
||||
* Initialize the device context spec factory
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(void) = 0;
|
||||
|
||||
/**
|
||||
* Get a device context specification. Typically, this
|
||||
* means getting information about a printer. A previously
|
||||
* returned device context spec can be passed in and used as
|
||||
* a starting point for getting a new spec (or simply returning
|
||||
* the old spec again). Additionally, if it is desirable to
|
||||
* get the device context spec without user intervention, any
|
||||
* dialog boxes can be supressed by passing in PR_TRUE for the
|
||||
* aQuiet parameter.
|
||||
* @param aWidget.. this is a widget a dialog can be hosted in
|
||||
* @param aNewSpec out parameter for device context spec returned. the
|
||||
* aOldSpec may be returned if the object is recyclable.
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,168 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIDrawingSurface_h___
|
||||
#define nsIDrawingSurface_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
// a memory area that can be rendered to
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PRUint32 mRedZeroMask; //red color mask in zero position
|
||||
PRUint32 mGreenZeroMask; //green color mask in zero position
|
||||
PRUint32 mBlueZeroMask; //blue color mask in zero position
|
||||
PRUint32 mAlphaZeroMask; //alpha data mask in zero position
|
||||
PRUint32 mRedMask; //red color mask
|
||||
PRUint32 mGreenMask; //green color mask
|
||||
PRUint32 mBlueMask; //blue color mask
|
||||
PRUint32 mAlphaMask; //alpha data mask
|
||||
PRUint8 mRedCount; //number of red color bits
|
||||
PRUint8 mGreenCount; //number of green color bits
|
||||
PRUint8 mBlueCount; //number of blue color bits
|
||||
PRUint8 mAlphaCount; //number of alpha data bits
|
||||
PRUint8 mRedShift; //number to shift value into red position
|
||||
PRUint8 mGreenShift; //number to shift value into green position
|
||||
PRUint8 mBlueShift; //number to shift value into blue position
|
||||
PRUint8 mAlphaShift; //number to shift value into alpha position
|
||||
} nsPixelFormat;
|
||||
|
||||
#define RASWIDTH(width, bpp) ((((width) * (bpp) + 31) >> 5) << 2)
|
||||
|
||||
#define NS_IDRAWING_SURFACE_IID \
|
||||
{ 0x61cc77e0, 0xcaac, 0x11d2, \
|
||||
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
class nsIDrawingSurface : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDRAWING_SURFACE_IID)
|
||||
/**
|
||||
* Lock a rect of a drawing surface and return a
|
||||
* pointer to the upper left hand corner of the
|
||||
* bitmap.
|
||||
* @param aX x position of subrect of bitmap
|
||||
* @param aY y position of subrect of bitmap
|
||||
* @param aWidth width of subrect of bitmap
|
||||
* @param aHeight height of subrect of bitmap
|
||||
* @param aBits out parameter for upper left hand
|
||||
* corner of bitmap
|
||||
* @param aStride out parameter for number of bytes
|
||||
* to add to aBits to go from scanline to scanline
|
||||
* @param aWidthBytes out parameter for number of
|
||||
* bytes per line in aBits to process aWidth pixels
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
/**
|
||||
* Unlock a rect of a drawing surface. must be preceded
|
||||
* by a call to Lock(). Lock()/Unlock() pairs do not nest.
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD Unlock(void) = 0;
|
||||
|
||||
/**
|
||||
* Get the dimensions of a drawing surface
|
||||
* @param aWidth out parameter for width of drawing surface
|
||||
* @param aHeight out parameter for height of drawing surface
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Get the offscreen status of the drawing surface
|
||||
* @param aOffscreen out parameter for offscreen status of
|
||||
* drawing surface. if PR_TRUE, then modifying the
|
||||
* drawing surface does not immediately reflect the
|
||||
* changes on the output device
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
|
||||
|
||||
/**
|
||||
* Get the pixel addressability status of the drawing surface
|
||||
* @param aAddressable out parameter for pixel addressability
|
||||
* status of drawing surface. if PR_TRUE, then the
|
||||
* drawing surface is optimized for pixel addressability
|
||||
* (i.e. the Lock() method has very low overhead). All
|
||||
* drawing surfaces support Lock()ing, but doing so on
|
||||
* drawing surfaces that do not return PR_TRUE here may
|
||||
* impose significant overhead.
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
|
||||
|
||||
/**
|
||||
* Get the pixel format of a drawing surface
|
||||
* @param aOffscreen out parameter filled in with pixel
|
||||
* format information.
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
|
||||
};
|
||||
|
||||
//when creating a drawing surface, you can use this
|
||||
//to tell the drawing surface that you anticipate
|
||||
//the need to get to the actual bits of the drawing
|
||||
//surface at some point during it's lifetime. typically
|
||||
//used when creating bitmaps to be operated on by the
|
||||
//nsIBlender implementations.
|
||||
#define NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS 0x0001
|
||||
|
||||
//flag to say that this drawing surface is shortlived,
|
||||
//which may affect how the OS allocates it. Used for
|
||||
//tiling, grouting etc.
|
||||
#define NS_CREATEDRAWINGSURFACE_SHORTLIVED 0x0002
|
||||
|
||||
//when locking a drawing surface, use these flags to
|
||||
//control how the data in the surface should be accessed
|
||||
#define NS_LOCK_SURFACE_READ_ONLY 0x0001
|
||||
#define NS_LOCK_SURFACE_WRITE_ONLY 0x0002
|
||||
|
||||
#endif // nsIDrawingSurface_h___
|
||||
@@ -1,228 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIFontMetrics_h___
|
||||
#define nsIFontMetrics_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCoord.h"
|
||||
|
||||
struct nsFont;
|
||||
class nsString;
|
||||
class nsIDeviceContext;
|
||||
class nsIAtom;
|
||||
|
||||
// IID for the nsIFontMetrics interface
|
||||
#define NS_IFONT_METRICS_IID \
|
||||
{ 0xc74cb770, 0xa33e, 0x11d1, \
|
||||
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A native font handle
|
||||
*/
|
||||
typedef void* nsFontHandle;
|
||||
|
||||
/**
|
||||
* Font metrics interface
|
||||
*
|
||||
* This interface may be somewhat misnamed. A better name might be
|
||||
* nsIFontList. The style system uses the nsFont struct for various font
|
||||
* properties, one of which is font-family, which can contain a *list* of
|
||||
* font names. The nsFont struct is "realized" by asking the device context
|
||||
* to cough up an nsIFontMetrics object, which contains a list of real font
|
||||
* handles, one for each font mentioned in font-family (and for each fallback
|
||||
* when we fall off the end of that list).
|
||||
*
|
||||
* The style system needs to have access to certain metrics, such as the
|
||||
* em height (for the CSS "em" unit), and we use the first Western font's
|
||||
* metrics for that purpose. The platform-specific implementations are
|
||||
* expected to select non-Western fonts that "fit" reasonably well with the
|
||||
* Western font that is loaded at Init time.
|
||||
*/
|
||||
class nsIFontMetrics : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IFONT_METRICS_IID)
|
||||
|
||||
/**
|
||||
* Initialize the font metrics. Call this after creating the font metrics.
|
||||
* Font metrics you get from the font cache do NOT need to be initialized
|
||||
*
|
||||
* @see nsIDeviceContext#GetMetricsFor()
|
||||
*/
|
||||
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIDeviceContext *aContext) = 0;
|
||||
|
||||
/**
|
||||
* Destroy this font metrics. This breaks the association between
|
||||
* the font metrics and the device context.
|
||||
*/
|
||||
NS_IMETHOD Destroy() = 0;
|
||||
|
||||
/**
|
||||
* Return the font's xheight property, scaled into app-units.
|
||||
*/
|
||||
NS_IMETHOD GetXHeight(nscoord& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Return the font's superscript offset (the distance from the
|
||||
* baseline to where a superscript's baseline should be placed). The
|
||||
* value returned will be a positive value.
|
||||
*/
|
||||
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Return the font's subscript offset (the distance from the
|
||||
* baseline to where a subscript's baseline should be placed). The
|
||||
* value returned will be a positive value.
|
||||
*/
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult) = 0;
|
||||
|
||||
/**
|
||||
* Return the font's strikeout offset (the distance from the
|
||||
* baseline to where a strikeout should be placed) and size
|
||||
* Positive values are above the baseline, negative below.
|
||||
*/
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize) = 0;
|
||||
|
||||
/**
|
||||
* Return the font's underline offset (the distance from the
|
||||
* baseline to where a underline should be placed) and size.
|
||||
* Positive values are above the baseline, negative below.
|
||||
*/
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize) = 0;
|
||||
|
||||
/**
|
||||
* Returns the height (in app units) of the font. This is ascent plus descent
|
||||
* plus any internal leading
|
||||
*
|
||||
* This method will be removed once the callers have been moved over to the
|
||||
* new GetEmHeight (and possibly GetMaxHeight).
|
||||
*/
|
||||
NS_IMETHOD GetHeight(nscoord &aHeight) = 0;
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_MAC) || defined(XP_BEOS)
|
||||
#define NEW_FONT_HEIGHT_APIS 1
|
||||
#endif
|
||||
#ifdef NEW_FONT_HEIGHT_APIS
|
||||
/**
|
||||
* Returns the normal line height (em height + leading).
|
||||
*/
|
||||
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight) = 0;
|
||||
#endif /* NEW_FONT_HEIGHT_APIS */
|
||||
|
||||
/**
|
||||
* Returns the amount of internal leading (in app units) for the font. This
|
||||
* is computed as the "height - (ascent + descent)"
|
||||
*/
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading) = 0;
|
||||
|
||||
#ifdef NEW_FONT_HEIGHT_APIS
|
||||
|
||||
/**
|
||||
* Returns the height (in app units) of the Western font's em square. This is
|
||||
* em ascent plus em descent.
|
||||
*/
|
||||
NS_IMETHOD GetEmHeight(nscoord &aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Returns, in app units, the ascent part of the Western font's em square.
|
||||
*/
|
||||
NS_IMETHOD GetEmAscent(nscoord &aAscent) = 0;
|
||||
|
||||
/**
|
||||
* Returns, in app units, the descent part of the Western font's em square.
|
||||
*/
|
||||
NS_IMETHOD GetEmDescent(nscoord &aDescent) = 0;
|
||||
|
||||
/**
|
||||
* Returns the height (in app units) of the Western font's bounding box.
|
||||
* This is max ascent plus max descent.
|
||||
*/
|
||||
NS_IMETHOD GetMaxHeight(nscoord &aHeight) = 0;
|
||||
|
||||
#endif /* NEW_FONT_HEIGHT_APIS */
|
||||
|
||||
/**
|
||||
* Returns, in app units, the maximum distance characters in this font extend
|
||||
* above the base line.
|
||||
*/
|
||||
NS_IMETHOD GetMaxAscent(nscoord &aAscent) = 0;
|
||||
|
||||
/**
|
||||
* Returns, in app units, the maximum distance characters in this font extend
|
||||
* below the base line.
|
||||
*/
|
||||
NS_IMETHOD GetMaxDescent(nscoord &aDescent) = 0;
|
||||
|
||||
/**
|
||||
* Returns, in app units, the maximum character advance for the font
|
||||
*/
|
||||
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance) = 0;
|
||||
|
||||
/**
|
||||
* Returns the font associated with these metrics
|
||||
*/
|
||||
NS_IMETHOD GetFont(const nsFont *&aFont) = 0;
|
||||
|
||||
/**
|
||||
* Returns the language group associated with these metrics
|
||||
*/
|
||||
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup) = 0;
|
||||
|
||||
/**
|
||||
* Returns the font handle associated with these metrics
|
||||
*/
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle) = 0;
|
||||
|
||||
#if defined(_WIN32) || defined(XP_OS2)
|
||||
/**
|
||||
* Returns the average character width
|
||||
*/
|
||||
NS_IMETHOD GetAveCharWidth(nscoord& aAveCharWidth) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the often needed width of the space character
|
||||
*/
|
||||
NS_IMETHOD GetSpaceWidth(nscoord& aSpaceCharWidth) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIFontMetrics_h___ */
|
||||
@@ -1,333 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIImage_h___
|
||||
#define nsIImage_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
struct nsRect;
|
||||
class nsIDeviceContext;
|
||||
|
||||
struct nsColorMap
|
||||
{
|
||||
//I lifted this from the image lib. The difference is that
|
||||
//this uses nscolor instead of NI_RGB. Multiple color pollution
|
||||
//is a bad thing. MMP
|
||||
PRInt32 NumColors; // Number of colors in the colormap.
|
||||
// A negative value can be used to denote a
|
||||
// possibly non-unique set.
|
||||
//nscolor *Map; // Colormap colors.
|
||||
PRUint8 *Index; // NULL, if map is in index order, otherwise
|
||||
// specifies the indices of the map entries. */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
nsMaskRequirements_kNoMask,
|
||||
nsMaskRequirements_kNeeds1Bit,
|
||||
nsMaskRequirements_kNeeds8Bit
|
||||
} nsMaskRequirements;
|
||||
|
||||
|
||||
#define nsImageUpdateFlags_kColorMapChanged 0x1
|
||||
#define nsImageUpdateFlags_kBitsChanged 0x2
|
||||
|
||||
// IID for the nsIImage interface
|
||||
#define NS_IIMAGE_IID \
|
||||
{ 0x0b4faaa0, 0xaa3a, 0x11d1, \
|
||||
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
// Interface to Images
|
||||
class nsIImage : public nsISupports
|
||||
{
|
||||
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IIMAGE_IID)
|
||||
|
||||
/**
|
||||
* Build and initialize the nsIImage
|
||||
* @param aWidth The width in pixels of the desired pixelmap
|
||||
* @param aHeight The height in pixels of the desired pixelmap
|
||||
* @param aDepth The number of bits per pixel for the pixelmap
|
||||
* @param aMaskRequirements A flag indicating if a alpha mask should be allocated
|
||||
*/
|
||||
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements) = 0;
|
||||
|
||||
/**
|
||||
* Get the number of bytes per pixel for this image
|
||||
* @update - dwc 2/3/99
|
||||
* @return - the number of bytes per pixel
|
||||
*/
|
||||
virtual PRInt32 GetBytesPix() = 0;
|
||||
|
||||
/**
|
||||
* Get whether rows are organized top to bottom, or bottom to top
|
||||
* @update - syd 3/29/99
|
||||
* @return PR_TRUE if top to bottom, else PR_FALSE
|
||||
*/
|
||||
virtual PRBool GetIsRowOrderTopToBottom() = 0;
|
||||
|
||||
/**
|
||||
* Get the width for the pixelmap
|
||||
* @update - dwc 2/1/99
|
||||
* @return The width in pixels for the pixelmap
|
||||
*/
|
||||
virtual PRInt32 GetWidth() = 0;
|
||||
|
||||
/**
|
||||
* Get the height for the pixelmap
|
||||
* @update - dwc 2/1/99
|
||||
* @return The height in pixels for the pixelmap
|
||||
*/
|
||||
virtual PRInt32 GetHeight() = 0;
|
||||
|
||||
/**
|
||||
* Set/Get the decoded dimensions for the pixelmap
|
||||
* 01/11/2000 - pnunn
|
||||
*/
|
||||
NS_IMETHOD SetDecodedRect(PRInt32, PRInt32, PRInt32, PRInt32) = 0;
|
||||
virtual PRInt32 GetDecodedX1() = 0;
|
||||
virtual PRInt32 GetDecodedY1() = 0;
|
||||
virtual PRInt32 GetDecodedX2() = 0;
|
||||
virtual PRInt32 GetDecodedY2() = 0;
|
||||
|
||||
NS_IMETHOD SetNaturalWidth(PRInt32) = 0;
|
||||
NS_IMETHOD SetNaturalHeight(PRInt32) = 0;
|
||||
virtual PRInt32 GetNaturalWidth() = 0;
|
||||
virtual PRInt32 GetNaturalHeight() = 0;
|
||||
|
||||
/**
|
||||
* Get a pointer to the bits for the pixelmap, only if it is not optimized
|
||||
* @update - dwc 2/1/99
|
||||
* @return address of the DIB pixel array
|
||||
*/
|
||||
virtual PRUint8 * GetBits() = 0;
|
||||
|
||||
/**
|
||||
* Get the number of bytes needed to get to the next scanline for the pixelmap
|
||||
* @update - dwc 2/1/99
|
||||
* @return The number of bytes in each scanline
|
||||
*/
|
||||
virtual PRInt32 GetLineStride() = 0;
|
||||
|
||||
/**
|
||||
* Get whether this image has an alpha mask. Preferable to testing
|
||||
* if GetAlphaBits() is non-null.
|
||||
* @update - sfraser 10/19/99
|
||||
* @return PR_TRUE if the image has an alpha mask, PR_FALSE otherwise
|
||||
*/
|
||||
virtual PRBool GetHasAlphaMask() = 0;
|
||||
|
||||
/**
|
||||
* Get a pointer to the bits for the alpha mask
|
||||
* @update - dwc 2/1/99
|
||||
* @return address of the alpha mask pixel array
|
||||
*/
|
||||
virtual PRUint8 * GetAlphaBits() = 0;
|
||||
|
||||
/**
|
||||
* Get the width of the alpha mask
|
||||
* @update - dwc 2/1/99
|
||||
* @return The width in pixels
|
||||
*/
|
||||
virtual PRInt32 GetAlphaWidth() = 0;
|
||||
|
||||
/**
|
||||
* Get the height of the alpha mask
|
||||
* @update - dwc 2/1/99
|
||||
* @return The width in pixels
|
||||
*/
|
||||
virtual PRInt32 GetAlphaHeight() = 0;
|
||||
|
||||
/**
|
||||
* Get the number of bytes per scanline for the alpha mask
|
||||
* @update - dwc 2/1/99
|
||||
* @return The number of bytes in each scanline
|
||||
*/
|
||||
virtual PRInt32 GetAlphaLineStride() = 0;
|
||||
|
||||
/**
|
||||
* Update the nsIImage color table
|
||||
* @update - dwc 2/1/99
|
||||
* @param aFlags Used to pass in parameters for the update
|
||||
* @param aUpdateRect The rectangle to update
|
||||
*/
|
||||
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect) = 0;
|
||||
|
||||
/**
|
||||
* Returns if the pixelmap has been converted to an optimized pixelmap
|
||||
* @update - dwc 2/1/99
|
||||
* @return If true, it is optimized
|
||||
*/
|
||||
virtual PRBool IsOptimized() = 0;
|
||||
|
||||
/**
|
||||
* Converted this pixelmap to an optimized pixelmap for the device
|
||||
* @update - dwc 2/1/99
|
||||
* @param aContext The device to optimize for
|
||||
* @return the result of the operation, if NS_OK, then the pixelmap is optimized
|
||||
*/
|
||||
virtual nsresult Optimize(nsIDeviceContext* aContext) = 0;
|
||||
|
||||
/**
|
||||
* Get the colormap for the nsIImage
|
||||
* @update - dwc 2/1/99
|
||||
* @return if non null, the colormap for the pixelmap,otherwise the image is not color mapped
|
||||
*/
|
||||
virtual nsColorMap * GetColorMap() = 0;
|
||||
|
||||
/**
|
||||
* BitBlit the nsIImage to a device, the source can be scaled to the dest
|
||||
* @update - dwc 2/1/99
|
||||
* @param aSurface the surface to blit to
|
||||
* @param aX The destination horizontal location
|
||||
* @param aY The destination vertical location
|
||||
* @param aWidth The destination width of the pixelmap
|
||||
* @param aHeight The destination height of the pixelmap
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* BitBlit the nsIImage to a device, the source and dest can be scaled
|
||||
* @update - dwc 2/1/99
|
||||
* @param aSurface the surface to blit to
|
||||
* @param aSX The source width of the pixelmap
|
||||
* @param aSY The source vertical location
|
||||
* @param aSWidth The source width of the pixelmap
|
||||
* @param aSHeight The source height of the pixelmap
|
||||
* @param aDX The destination horizontal location
|
||||
* @param aDY The destination vertical location
|
||||
* @param aDWidth The destination width of the pixelmap
|
||||
* @param aDHeight The destination height of the pixelmap
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
||||
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect) = 0;
|
||||
|
||||
/**
|
||||
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
|
||||
* @update - saari 03/08/01
|
||||
* @param aDstImage the nsImage to blit to
|
||||
* @param aDX The destination horizontal location
|
||||
* @param aDY The destination vertical location
|
||||
* @param aDWidth The destination width of the pixelmap
|
||||
* @param aDHeight The destination height of the pixelmap
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
||||
|
||||
/**
|
||||
* Set the alpha level for the image
|
||||
* @update - dwc 2/1/99
|
||||
* @param the alpha level to set for the image, from 0 to 100%
|
||||
*/
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel) = 0;
|
||||
|
||||
/**
|
||||
* Get the alpha level for the image
|
||||
* @update - dwc 2/1/99
|
||||
* @return the alpha level for the image, from 0 to 100%
|
||||
*/
|
||||
virtual PRInt32 GetAlphaLevel() = 0;
|
||||
|
||||
/**
|
||||
* Get the alpha depth for the image mask
|
||||
* @update - lordpixel 2001/05/16
|
||||
* @return the alpha mask depth for the image, ie, 0, 1 or 8
|
||||
*/
|
||||
virtual PRInt8 GetAlphaDepth() = 0;
|
||||
|
||||
/**
|
||||
* Return information about the bits for this structure
|
||||
* @update - dwc 2/1/99
|
||||
* @return a bitmap info structure for the Device Dependent Bits
|
||||
*/
|
||||
virtual void* GetBitInfo() = 0;
|
||||
|
||||
|
||||
/**
|
||||
* LockImagePixels
|
||||
* Lock the image pixels so that we can access them directly,
|
||||
* with safely. May be a noop on some platforms.
|
||||
*
|
||||
* aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
|
||||
*
|
||||
* Must be balanced by a call to UnlockImagePixels().
|
||||
*
|
||||
* @update - sfraser 10/18/99
|
||||
* @return error result
|
||||
*/
|
||||
NS_IMETHOD LockImagePixels(PRBool aMaskPixels) = 0;
|
||||
|
||||
/**
|
||||
* UnlockImagePixels
|
||||
* Unlock the image pixels. May be a noop on some platforms.
|
||||
*
|
||||
* Should balance an earlier call to LockImagePixels().
|
||||
*
|
||||
* aMaskPixels = PR_TRUE for the mask, PR_FALSE for the image
|
||||
*
|
||||
* @update - sfraser 10/18/99
|
||||
* @return error result
|
||||
*/
|
||||
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels) = 0;
|
||||
|
||||
//get the color space metrics for this image
|
||||
//virtual NI_ColorSpec * GetColorSpec() = 0; fix
|
||||
|
||||
//get the color which should be considered transparent.
|
||||
//if this image is color mapped, this value will be an
|
||||
//index into the color map. hokey? yes, but it avoids
|
||||
//another silly api or struct.
|
||||
//virtual nscolor GetTransparentColor() = 0; fix.
|
||||
};
|
||||
|
||||
//change notification API flag bits
|
||||
#define NS_IMAGE_UPDATE_COLORMAP 1
|
||||
#define NS_IMAGE_UPDATE_PIXELS 2
|
||||
#define NS_IMAGE_UPDATE_ALPHA 4
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick C. Beard <beard@netscape.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIPrintingContextMac_h___
|
||||
#define nsIPrintingContextMac_h___
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIPrintSettings;
|
||||
|
||||
// 3d5917da-1dd2-11b2-bc7b-aa83823362e0
|
||||
#define NS_IPRINTING_CONTEXT_IID \
|
||||
{ 0x3d5917da, 0x1dd2, 0x11b2, \
|
||||
{ 0xbc, 0x7b, 0xaa, 0x83, 0x82, 0x33, 0x62, 0xe0 } }
|
||||
|
||||
class nsIPrintingContext : public nsISupports {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID)
|
||||
/**
|
||||
* Initialize the printing context for use.
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet) = 0;
|
||||
|
||||
/**
|
||||
* This will tell if the printmanager is currently open
|
||||
* @update dc 12/03/98
|
||||
* @param aIsOpen True or False depending if the printmanager is open
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen) = 0;
|
||||
|
||||
/**
|
||||
* Closes the printmanager if it is open.
|
||||
* @update dc 12/03/98
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD ClosePrintManager() = 0;
|
||||
|
||||
NS_IMETHOD BeginDocument() = 0;
|
||||
|
||||
NS_IMETHOD EndDocument() = 0;
|
||||
|
||||
NS_IMETHOD BeginPage() = 0;
|
||||
|
||||
NS_IMETHOD EndPage() = 0;
|
||||
|
||||
NS_IMETHOD GetPrinterResolution(double* aResolution) = 0;
|
||||
|
||||
NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIPrintingContextMac_h___ */
|
||||
@@ -1,279 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIRegion_h___
|
||||
#define nsIRegion_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsRect.h"
|
||||
|
||||
enum nsRegionComplexity
|
||||
{
|
||||
eRegionComplexity_empty = 0,
|
||||
eRegionComplexity_rect = 1,
|
||||
eRegionComplexity_complex = 2
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PRInt32 x;
|
||||
PRInt32 y;
|
||||
PRUint32 width;
|
||||
PRUint32 height;
|
||||
} nsRegionRect;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PRUint32 mNumRects; //number of actual rects in the mRects array
|
||||
PRUint32 mRectsLen; //length, in rects, of the mRects array
|
||||
PRUint32 mArea; //area of the covered portion of the region
|
||||
nsRegionRect mRects[1];
|
||||
} nsRegionRectSet;
|
||||
|
||||
// An implementation of a region primitive that can be used to
|
||||
// represent arbitrary pixel areas. Probably implemented on top
|
||||
// of the native region primitive. The assumption is that, at worst,
|
||||
// it is a rectangle list.
|
||||
|
||||
#define NS_IREGION_IID \
|
||||
{ 0x8ef366e0, 0xee94, 0x11d1, \
|
||||
{ 0xa8, 0x2a, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
|
||||
|
||||
class nsIRegion : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IREGION_IID)
|
||||
|
||||
virtual nsresult Init(void) = 0;
|
||||
|
||||
/**
|
||||
* copy operator equivalent that takes another region
|
||||
*
|
||||
* @param region to copy
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void SetTo(const nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* copy operator equivalent that takes a rect
|
||||
*
|
||||
* @param aX xoffset of rect to set region to
|
||||
* @param aY yoffset of rect to set region to
|
||||
* @param aWidth width of rect to set region to
|
||||
* @param aHeight height of rect to set region to
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* destructively intersect another region with this one
|
||||
*
|
||||
* @param region to intersect
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Intersect(const nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* destructively intersect a rect with this region
|
||||
*
|
||||
* @param aX xoffset of rect to intersect with region
|
||||
* @param aY yoffset of rect to intersect with region
|
||||
* @param aWidth width of rect to intersect with region
|
||||
* @param aHeight height of rect to intersect with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* destructively union another region with this one
|
||||
*
|
||||
* @param region to union
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Union(const nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* destructively union a rect with this region
|
||||
*
|
||||
* @param aX xoffset of rect to union with region
|
||||
* @param aY yoffset of rect to union with region
|
||||
* @param aWidth width of rect to union with region
|
||||
* @param aHeight height of rect to union with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* destructively subtract another region with this one
|
||||
*
|
||||
* @param region to subtract
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Subtract(const nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* destructively subtract a rect from this region
|
||||
*
|
||||
* @param aX xoffset of rect to subtract with region
|
||||
* @param aY yoffset of rect to subtract with region
|
||||
* @param aWidth width of rect to subtract with region
|
||||
* @param aHeight height of rect to subtract with region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
|
||||
virtual void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* is this region empty? i.e. does it contain any pixels
|
||||
*
|
||||
* @param none
|
||||
* @return returns whether the region is empty
|
||||
*
|
||||
**/
|
||||
|
||||
virtual PRBool IsEmpty(void) = 0;
|
||||
|
||||
/**
|
||||
* == operator equivalent i.e. do the regions contain exactly
|
||||
* the same pixels
|
||||
*
|
||||
* @param region to compare
|
||||
* @return whether the regions are identical
|
||||
*
|
||||
**/
|
||||
|
||||
virtual PRBool IsEqual(const nsIRegion &aRegion) = 0;
|
||||
|
||||
/**
|
||||
* returns the bounding box of the region i.e. the smallest
|
||||
* rectangle that completely contains the region.
|
||||
*
|
||||
* @param aX out parameter for xoffset of bounding rect for region
|
||||
* @param aY out parameter for yoffset of bounding rect for region
|
||||
* @param aWidth out parameter for width of bounding rect for region
|
||||
* @param aHeight out parameter for height of bounding rect for region
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
virtual void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight) = 0;
|
||||
|
||||
/**
|
||||
* offsets the region in x and y
|
||||
*
|
||||
* @param xoffset pixel offset in x
|
||||
* @param yoffset pixel offset in y
|
||||
* @return void
|
||||
*
|
||||
**/
|
||||
virtual void Offset(PRInt32 aXOffset, PRInt32 aYOffset) = 0;
|
||||
|
||||
/**
|
||||
* does the region intersect the rectangle?
|
||||
*
|
||||
* @param rect to check for containment
|
||||
* @return true if the region intersects the rect
|
||||
*
|
||||
**/
|
||||
|
||||
virtual PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
|
||||
|
||||
/**
|
||||
* get the set of rects which make up this region. the aRects
|
||||
* parameter must be freed by calling FreeRects before the region
|
||||
* is deleted. aRects may be passed in again when requesting
|
||||
* the rect list as a recycling method.
|
||||
*
|
||||
* @param aRects out parameter containing set of rects
|
||||
* comprising the region
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetRects(nsRegionRectSet **aRects) = 0;
|
||||
|
||||
/**
|
||||
* Free a rect set returned by GetRects.
|
||||
*
|
||||
* @param aRects rects to free
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD FreeRects(nsRegionRectSet *aRects) = 0;
|
||||
|
||||
/**
|
||||
* Get the native region that this nsIRegion represents.
|
||||
* @param aRegion out parameter for native region handle
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const = 0;
|
||||
|
||||
/**
|
||||
* Get the complexity of the region as defined by the
|
||||
* nsRegionComplexity enum.
|
||||
* @param aComplexity out parameter for region complexity
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0;
|
||||
|
||||
/**
|
||||
* get the number of rects which make up this region.
|
||||
*
|
||||
* @param aRects out parameter containing the number of rects
|
||||
* comprising the region
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRegion_h___
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,80 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (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.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: David W. Hyatt (hyatt@netscape.com)
|
||||
*
|
||||
* Contributors:
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsColor.h"
|
||||
|
||||
struct nsRect;
|
||||
struct nsSize;
|
||||
struct nsFont;
|
||||
struct nsMargin;
|
||||
class nsIPresContext;
|
||||
class nsIRenderingContext;
|
||||
class nsIDeviceContext;
|
||||
class nsIFrame;
|
||||
class nsIAtom;
|
||||
|
||||
// IID for the nsITheme interface
|
||||
// {F791038C-F97E-4068-A542-0343AE440664}
|
||||
#define NS_ITHEME_IID \
|
||||
{ 0xf791038c, 0xf97e, 0x4068, { 0xa5, 0x42, 0x3, 0x43, 0xae, 0x44, 0x6, 0x64 } }
|
||||
|
||||
// {D930E29B-6909-44e5-AB4B-AF10D6923705}
|
||||
#define NS_THEMERENDERER_CID \
|
||||
{ 0xd930e29b, 0x6909, 0x44e5, { 0xab, 0x4b, 0xaf, 0x10, 0xd6, 0x92, 0x37, 0x5 } }
|
||||
|
||||
class nsITheme: public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ITHEME_IID; return iid; }
|
||||
|
||||
NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
const nsRect& aRect,
|
||||
const nsRect& aClipRect)=0;
|
||||
|
||||
NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext,
|
||||
nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsMargin* aResult)=0;
|
||||
|
||||
NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame* aFrame,
|
||||
PRUint8 aWidgetType,
|
||||
nsSize* aResult,
|
||||
PRBool* aIsOverridable)=0;
|
||||
|
||||
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
nsIAtom* aAttribute, PRBool* aShouldRepaint)=0;
|
||||
|
||||
NS_IMETHOD ThemeChanged()=0;
|
||||
|
||||
virtual PRBool ThemeSupportsWidget(nsIPresContext* aPresContext,
|
||||
PRUint8 aWidgetType)=0;
|
||||
|
||||
virtual PRBool WidgetIsContainer(PRUint8 aWidgetType)=0;
|
||||
};
|
||||
|
||||
// Creator function
|
||||
extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSMARGIN_H
|
||||
#define NSMARGIN_H
|
||||
|
||||
#include "nsCoord.h"
|
||||
|
||||
struct nsMargin {
|
||||
nscoord left, top, right, bottom;
|
||||
|
||||
// Constructors
|
||||
nsMargin() {}
|
||||
nsMargin(const nsMargin& aMargin) {*this = aMargin;}
|
||||
nsMargin(nscoord aLeft, nscoord aTop,
|
||||
nscoord aRight, nscoord aBottom) {left = aLeft; top = aTop;
|
||||
right = aRight; bottom = aBottom;}
|
||||
|
||||
void SizeTo(nscoord aLeft, nscoord aTop,
|
||||
nscoord aRight, nscoord aBottom) {left = aLeft; top = aTop;
|
||||
right = aRight; bottom = aBottom;}
|
||||
void SizeBy(nscoord aLeft, nscoord aTop,
|
||||
nscoord aRight, nscoord aBottom) {left += aLeft; top += aTop;
|
||||
right += aRight; bottom += aBottom;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsMargin& aMargin) const {
|
||||
return (PRBool) ((left == aMargin.left) && (top == aMargin.top) &&
|
||||
(right == aMargin.right) && (bottom == aMargin.bottom));
|
||||
}
|
||||
PRBool operator!=(const nsMargin& aMargin) const {
|
||||
return (PRBool) ((left != aMargin.left) || (top != aMargin.top) ||
|
||||
(right != aMargin.right) || (bottom != aMargin.bottom));
|
||||
}
|
||||
nsMargin operator+(const nsMargin& aMargin) const {
|
||||
return nsMargin(left + aMargin.left, top + aMargin.top,
|
||||
right + aMargin.right, bottom + aMargin.bottom);
|
||||
}
|
||||
nsMargin operator-(const nsMargin& aMargin) const {
|
||||
return nsMargin(left - aMargin.left, top - aMargin.top,
|
||||
right - aMargin.right, bottom - aMargin.bottom);
|
||||
}
|
||||
nsMargin& operator+=(const nsMargin& aMargin) {left += aMargin.left;
|
||||
top += aMargin.top;
|
||||
right += aMargin.right;
|
||||
bottom += aMargin.bottom;
|
||||
return *this;}
|
||||
nsMargin& operator-=(const nsMargin& aMargin) {left -= aMargin.left;
|
||||
top -= aMargin.top;
|
||||
right -= aMargin.right;
|
||||
bottom -= aMargin.bottom;
|
||||
return *this;}
|
||||
};
|
||||
|
||||
#endif /* NSMARGIN_H */
|
||||
@@ -1,141 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSPOINT_H
|
||||
#define NSPOINT_H
|
||||
|
||||
#include "nsCoord.h"
|
||||
|
||||
struct nsPoint {
|
||||
nscoord x, y;
|
||||
|
||||
// Constructors
|
||||
nsPoint() {}
|
||||
nsPoint(const nsPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
|
||||
nsPoint(nscoord aX, nscoord aY) {x = aX; y = aY;}
|
||||
|
||||
void MoveTo(nscoord aX, nscoord aY) {x = aX; y = aY;}
|
||||
void MoveBy(nscoord aDx, nscoord aDy) {x += aDx; y += aDy;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsPoint& aPoint) const {
|
||||
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
|
||||
}
|
||||
PRBool operator!=(const nsPoint& aPoint) const {
|
||||
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
|
||||
}
|
||||
nsPoint operator+(const nsPoint& aPoint) const {
|
||||
return nsPoint(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
nsPoint operator-(const nsPoint& aPoint) const {
|
||||
return nsPoint(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
nsPoint& operator+=(const nsPoint& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
nsPoint& operator-=(const nsPoint& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A point structure with floats for the Quadratic bezier curve
|
||||
* @update 4/27/2000 dwc
|
||||
*/
|
||||
struct nsFloatPoint {
|
||||
float x, y;
|
||||
|
||||
// Constructors
|
||||
nsFloatPoint() {}
|
||||
nsFloatPoint(const nsFloatPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
|
||||
nsFloatPoint(float aX, float aY) {x = aX; y = aY;}
|
||||
|
||||
void MoveTo(float aX, float aY) {x = aX; y = aY;}
|
||||
void MoveTo(nscoord aX, nscoord aY) {x = (float)aX; y = (float)aY;}
|
||||
void MoveBy(float aDx, float aDy) {x += aDx; y += aDy;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsFloatPoint& aPoint) const {
|
||||
return (PRBool) ((x == aPoint.x) && (y == aPoint.y));
|
||||
}
|
||||
PRBool operator!=(const nsFloatPoint& aPoint) const {
|
||||
return (PRBool) ((x != aPoint.x) || (y != aPoint.y));
|
||||
}
|
||||
nsFloatPoint operator+(const nsFloatPoint& aPoint) const {
|
||||
return nsFloatPoint(x + aPoint.x, y + aPoint.y);
|
||||
}
|
||||
nsFloatPoint operator-(const nsFloatPoint& aPoint) const {
|
||||
return nsFloatPoint(x - aPoint.x, y - aPoint.y);
|
||||
}
|
||||
nsFloatPoint& operator+=(const nsFloatPoint& aPoint) {
|
||||
x += aPoint.x;
|
||||
y += aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
nsFloatPoint& operator-=(const nsFloatPoint& aPoint) {
|
||||
x -= aPoint.x;
|
||||
y -= aPoint.y;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A special type of point which also add the capability to tell if a point is on
|
||||
* the curve.. or off of the curve for a path
|
||||
* @update 03/29/00 dwc
|
||||
*/
|
||||
struct nsPathPoint: public nsFloatPoint{
|
||||
|
||||
PRBool mIsOnCurve;
|
||||
|
||||
// Constructors
|
||||
nsPathPoint() {}
|
||||
nsPathPoint(const nsPathPoint& aPoint) {x = aPoint.x; y = aPoint.y;mIsOnCurve=aPoint.mIsOnCurve;}
|
||||
nsPathPoint(float aX, float aY) {x = aX; y = aY;mIsOnCurve=PR_TRUE;}
|
||||
nsPathPoint(float aX, float aY,PRBool aIsOnCurve) {x = aX; y = aY;mIsOnCurve=aIsOnCurve;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* NSPOINT_H */
|
||||
@@ -1,152 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
|
||||
#ifndef NSRECT_H
|
||||
#define NSRECT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsCoord.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsMargin.h"
|
||||
#include "nsUnitConversion.h"
|
||||
|
||||
struct NS_GFX nsRect {
|
||||
nscoord x, y;
|
||||
nscoord width, height;
|
||||
|
||||
// Constructors
|
||||
nsRect() : x(0), y(0), width(0), height(0) {}
|
||||
nsRect(const nsRect& aRect) {*this = aRect;}
|
||||
nsRect(const nsPoint& aOrigin, const nsSize &aSize) {x = aOrigin.x; y = aOrigin.y;
|
||||
width = aSize.width; height = aSize.height;}
|
||||
nsRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) {x = aX; y = aY;
|
||||
width = aWidth; height = aHeight;}
|
||||
|
||||
// Emptiness. An empty rect is one that has no area, i.e. its height or width
|
||||
// is <= 0
|
||||
PRBool IsEmpty() const {
|
||||
return (PRBool) ((height <= 0) || (width <= 0));
|
||||
}
|
||||
void Empty() {width = height = 0;}
|
||||
|
||||
// Containment
|
||||
PRBool Contains(const nsRect& aRect) const;
|
||||
PRBool Contains(nscoord aX, nscoord aY) const;
|
||||
PRBool Contains(const nsPoint& aPoint) const {return Contains(aPoint.x, aPoint.y);}
|
||||
|
||||
// Intersection. Returns TRUE if the receiver overlaps aRect and
|
||||
// FALSE otherwise
|
||||
PRBool Intersects(const nsRect& aRect) const;
|
||||
|
||||
// Computes the area in which aRect1 and aRect2 overlap, and fills 'this' with
|
||||
// the result. Returns FALSE if the rectangles don't intersect, and sets 'this'
|
||||
// rect to be an empty rect.
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
PRBool IntersectRect(const nsRect& aRect1, const nsRect& aRect2);
|
||||
|
||||
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
|
||||
// fills 'this' with the result. Returns FALSE and sets 'this' rect to be an
|
||||
// empty rect if both aRect1 and aRect2 are empty
|
||||
//
|
||||
// 'this' can be the same object as either aRect1 or aRect2
|
||||
PRBool UnionRect(const nsRect& aRect1, const nsRect& aRect2);
|
||||
|
||||
// Accessors
|
||||
void SetRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) {
|
||||
x = aX; y = aY; width = aWidth; height = aHeight;
|
||||
}
|
||||
void MoveTo(nscoord aX, nscoord aY) {x = aX; y = aY;}
|
||||
void MoveTo(const nsPoint& aPoint) {x = aPoint.x; y = aPoint.y;}
|
||||
void MoveBy(nscoord aDx, nscoord aDy) {x += aDx; y += aDy;}
|
||||
void SizeTo(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
|
||||
void SizeTo(const nsSize& aSize) {SizeTo(aSize.width, aSize.height);}
|
||||
void SizeBy(nscoord aDeltaWidth, nscoord aDeltaHeight) {width += aDeltaWidth;
|
||||
height += aDeltaHeight;}
|
||||
|
||||
// Inflate the rect by the specified width/height or margin
|
||||
void Inflate(nscoord aDx, nscoord aDy);
|
||||
void Inflate(const nsSize& aSize) {Inflate(aSize.width, aSize.height);}
|
||||
void Inflate(const nsMargin& aMargin);
|
||||
|
||||
// Deflate the rect by the specified width/height or margin
|
||||
void Deflate(nscoord aDx, nscoord aDy);
|
||||
void Deflate(const nsSize& aSize) {Deflate(aSize.width, aSize.height);}
|
||||
void Deflate(const nsMargin& aMargin);
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator.
|
||||
PRBool operator==(const nsRect& aRect) const {
|
||||
return (PRBool) ((IsEmpty() && aRect.IsEmpty()) ||
|
||||
((x == aRect.x) && (y == aRect.y) &&
|
||||
(width == aRect.width) && (height == aRect.height)));
|
||||
}
|
||||
PRBool operator!=(const nsRect& aRect) const {
|
||||
return (PRBool) !operator==(aRect);
|
||||
}
|
||||
nsRect operator+(const nsRect& aRect) const {
|
||||
return nsRect(x + aRect.x, y + aRect.y,
|
||||
width + aRect.width, height + aRect.height);
|
||||
}
|
||||
nsRect operator-(const nsRect& aRect) const {
|
||||
return nsRect(x - aRect.x, y - aRect.y,
|
||||
width - aRect.width, height - aRect.height);
|
||||
}
|
||||
nsRect& operator+=(const nsPoint& aPoint) {x += aPoint.x; y += aPoint.y; return *this;}
|
||||
nsRect& operator-=(const nsPoint& aPoint) {x -= aPoint.x; y -= aPoint.y; return *this;}
|
||||
|
||||
nsRect& operator*=(const float aScale) {x = NSToCoordRound(x * aScale);
|
||||
y = NSToCoordRound(y * aScale);
|
||||
width = NSToCoordRound(width * aScale);
|
||||
height = NSToCoordRound(height * aScale);
|
||||
return *this;}
|
||||
|
||||
nsRect& ScaleRoundOut(const float aScale);
|
||||
nsRect& ScaleRoundIn(const float aScale);
|
||||
|
||||
// Helper methods for computing the extents
|
||||
nscoord XMost() const {return x + width;}
|
||||
nscoord YMost() const {return y + height;}
|
||||
};
|
||||
|
||||
// Diagnostics
|
||||
extern NS_GFX FILE* operator<<(FILE* out, const nsRect& rect);
|
||||
|
||||
#endif /* NSRECT_H */
|
||||
@@ -1,299 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsRenderingContextImpl_h___
|
||||
#define nsRenderingContextImpl_h___
|
||||
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsPoint.h"
|
||||
#include "nsSize.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
double x; // x coordinate of edge's intersection with current scanline */
|
||||
double dx; // change in x with respect to y
|
||||
int i; // edge number: edge i goes from mPointList[i] to mPointList[i+1]
|
||||
} Edge;
|
||||
|
||||
|
||||
class NS_GFX nsRenderingContextImpl : public nsIRenderingContext
|
||||
{
|
||||
|
||||
// CLASS MEMBERS
|
||||
public:
|
||||
|
||||
|
||||
protected:
|
||||
nsTransform2D *mTranMatrix; // The rendering contexts transformation matrix
|
||||
nsLineStyle mLineStyle; // The current linestyle, currenly used on mac, other platfroms to follow
|
||||
int mAct; // number of active edges
|
||||
Edge *mActive; // active edge list:edges crossing scanline y
|
||||
|
||||
public:
|
||||
nsRenderingContextImpl();
|
||||
|
||||
|
||||
// CLASS METHODS
|
||||
|
||||
/**
|
||||
* Gets the Pen Mode for the RenderingContext
|
||||
* @param aPenMode The Pen Mode to be retrieved
|
||||
* @return NS_OK if the Pen Mode is correctly retrieved
|
||||
*/
|
||||
NS_IMETHOD GetPenMode(nsPenMode &aPenMode) { return NS_ERROR_FAILURE;}
|
||||
|
||||
/**
|
||||
* Sets the Pen Mode for the RenderingContext
|
||||
* @param aPenMode The Pen Mode
|
||||
* @return NS_OK if the Pen Mode is correctly set
|
||||
*/
|
||||
NS_IMETHOD SetPenMode(nsPenMode aPenMode) { return NS_ERROR_FAILURE;};
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 03/29/00 dwc
|
||||
*/
|
||||
NS_IMETHOD DrawPath(nsPathPoint aPointArray[],PRInt32 aNumPts);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 03/29/00 dwc
|
||||
*/
|
||||
NS_IMETHOD FillPath(nsPathPoint aPointArray[],PRInt32 aNumPts);
|
||||
|
||||
/**
|
||||
* Fill a poly in the current foreground color
|
||||
* @param aPoints points to use for the drawing, last must equal first
|
||||
* @param aNumPonts number of points in the polygon
|
||||
*/
|
||||
NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 05/01/00 dwc
|
||||
*/
|
||||
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) { return NS_OK;}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 05/01/00 dwc
|
||||
*/
|
||||
NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
|
||||
NS_IMETHOD ReleaseBackbuffer(void);
|
||||
NS_IMETHOD DestroyCachedBackbuffer(void);
|
||||
|
||||
#ifdef IBMBIDI
|
||||
/**
|
||||
* Let the device context know whether we want text reordered with
|
||||
* right-to-left base direction
|
||||
*/
|
||||
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
|
||||
#endif // IBMBIDI
|
||||
|
||||
#ifdef USE_IMG2
|
||||
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
|
||||
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
|
||||
NS_IMETHOD DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect);
|
||||
NS_IMETHOD DrawScaledTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, nscoord aTileWidth, nscoord aTileHeight, const nsRect * aTargetRect);
|
||||
#endif
|
||||
|
||||
|
||||
protected:
|
||||
virtual ~nsRenderingContextImpl();
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Check to see if the given size of tile can be imaged by the RenderingContext
|
||||
* @update 03/29/00 dwc
|
||||
* @param aWidth The width of the tile
|
||||
* @param aHeight The height of the tile
|
||||
* @return PR_TRUE the RenderingContext can handle this tile
|
||||
*/
|
||||
virtual PRBool CanTile(nscoord aWidth,nscoord aHeight) { return PR_FALSE; }
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A bit blitter to tile images to the background recursively
|
||||
* @update 3/29/00 dwc
|
||||
* @param aDS -- Target drawing surface for the rendering context
|
||||
* @param aSrcRect -- Rectangle we are build with the image
|
||||
* @param aHeight -- height of the tile
|
||||
* @param aWidth -- width of the tile
|
||||
*/
|
||||
void TileImage(nsDrawingSurface aDS,nsRect &aSrcRect,PRInt16 aWidth,PRInt16 aHeight);
|
||||
|
||||
void cdelete(int i);
|
||||
void cinsert(int i,int y,const nsPoint aPointArray[],PRInt32 aNumPts);
|
||||
|
||||
/**
|
||||
* Determine if a rect's width and height will fit within a specified width and height
|
||||
* @param aRect rectangle to test
|
||||
* @param aWidth width to determine if the rectangle's width will fit within
|
||||
* @param aHeight height to determine if the rectangles height will fit within
|
||||
* @returns PR_TRUE if the rect width and height fits with aWidth, aHeight, PR_FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
|
||||
PRBool RectFitsInside(const nsRect& aRect, PRInt32 aWidth, PRInt32 aHeight) const;
|
||||
|
||||
/**
|
||||
* Determine if two rectangles width and height will fit within a specified width and height
|
||||
* @param aRect1 first rectangle to test
|
||||
* @param aRect1 second rectangle to test
|
||||
* @param aWidth width to determine if both rectangle's width will fit within
|
||||
* @param aHeight height to determine if both rectangles height will fit within
|
||||
* @returns PR_TRUE if the rect1's and rect2's width and height fits with aWidth,
|
||||
* aHeight, PR_FALSE otherwise.
|
||||
*/
|
||||
PRBool BothRectsFitInside(const nsRect& aRect1, const nsRect& aRect2, PRInt32 aWidth, PRInt32 aHeight, nsRect& aNewSize) const;
|
||||
|
||||
/**
|
||||
* Return an offscreen surface size from a set of discrete surface sizes.
|
||||
* The smallest discrete surface size that can enclose both the Maximum widget
|
||||
* size (@see GetMaxWidgetBounds) and the requested size is returned.
|
||||
*
|
||||
* @param aMaxBackbufferSize Maximum size that may be requested for the backbuffer
|
||||
* @param aRequestedSize Requested size for the offscreen.
|
||||
* @param aSurfaceSize contains the surface size
|
||||
*/
|
||||
void CalculateDiscreteSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSize);
|
||||
|
||||
/**
|
||||
* Get the size of the offscreen drawing surface..
|
||||
*
|
||||
* @param aMaxBackbufferSize Maximum size that may be requested for the backbuffer
|
||||
* @param aRequestedSize Desired size for the offscreen.
|
||||
* @param aSurfaceSize Offscreen adjusted to a discrete size which encloses aRequestedSize.
|
||||
*/
|
||||
void GetDrawingSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSurfaceSize);
|
||||
|
||||
/**
|
||||
* Utility method used to implement NS_IMETHOD GetBackbuffer
|
||||
*
|
||||
* @param aRequestedSize size of the backbuffer area requested
|
||||
* @param aMaxSize maximum size that may be requested for the backbuffer
|
||||
* @param aBackbuffer drawing surface used as the backbuffer
|
||||
* @param aCacheBackbuffer PR_TRUE then the backbuffer will be cached, if PR_FALSE it is created each time
|
||||
*/
|
||||
nsresult AllocateBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer, PRBool aCacheBackbuffer);
|
||||
|
||||
public:
|
||||
|
||||
protected:
|
||||
nsPenMode mPenMode;
|
||||
private:
|
||||
static nsDrawingSurface gBackbuffer; //singleton backbuffer
|
||||
static nsRect gBackbufferBounds; //backbuffer bounds
|
||||
// Largest requested offscreen size if larger than a full screen.
|
||||
static nsSize gLargestRequestedSize;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Class QBezierCurve, a quadratic bezier curve
|
||||
* @update 4/27/2000 dwc
|
||||
*/
|
||||
class QBezierCurve
|
||||
{
|
||||
|
||||
public:
|
||||
nsFloatPoint mAnc1;
|
||||
nsFloatPoint mCon;
|
||||
nsFloatPoint mAnc2;
|
||||
|
||||
QBezierCurve() {mAnc1.x=0;mAnc1.y=0;mCon=mAnc2=mAnc1;}
|
||||
void SetControls(nsFloatPoint &aAnc1,nsFloatPoint &aCon,nsFloatPoint &aAnc2) { mAnc1 = aAnc1; mCon = aCon; mAnc2 = aAnc2;}
|
||||
void SetPoints(nscoord a1x,nscoord a1y,nscoord acx,nscoord acy,nscoord a2x,nscoord a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
|
||||
void SetPoints(float a1x,float a1y,float acx,float acy,float a2x,float a2y) {mAnc1.MoveTo(a1x,a1y),mCon.MoveTo(acx,acy),mAnc2.MoveTo(a2x,a2y);}
|
||||
void DebugPrint();
|
||||
/** ---------------------------------------------------
|
||||
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
|
||||
* else it is so small that it can be approximated by 2 lineto calls
|
||||
* @param aRenderingContext -- The RenderingContext to use to draw with
|
||||
* @update 3/26/99 dwc
|
||||
*/
|
||||
void SubDivide(nsIRenderingContext *aRenderingContext);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Divide a Quadratic curve into line segments if it is not smaller than a certain size
|
||||
* else it is so small that it can be approximated by 2 lineto calls
|
||||
* @param nsPoint* -- The points array to rasterize into
|
||||
* @param aNumPts* -- Current number of points in this array
|
||||
* @update 3/26/99 dwc
|
||||
*/
|
||||
void SubDivide(nsPoint aThePoints[],PRInt16 *aNumPts);
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* Divide a Quadratic Bezier curve at the mid-point
|
||||
* @update 3/26/99 dwc
|
||||
* @param aCurve1 -- Curve 1 as a result of the division
|
||||
* @param aCurve2 -- Curve 2 as a result of the division
|
||||
*/
|
||||
void MidPointDivide(QBezierCurve *A,QBezierCurve *B);
|
||||
};
|
||||
|
||||
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* A class to iterate through a nsPathPoint array and return segments
|
||||
* @update 04/27/00 dwc
|
||||
*/
|
||||
class nsPathIter {
|
||||
|
||||
public:
|
||||
enum eSegType {eUNDEF,eLINE,eQCURVE,eCCURVE};
|
||||
|
||||
private:
|
||||
PRUint32 mCurPoint;
|
||||
PRUint32 mNumPoints;
|
||||
nsPathPoint *mThePath;
|
||||
|
||||
public:
|
||||
nsPathIter();
|
||||
nsPathIter(nsPathPoint* aThePath,PRUint32 aNumPts);
|
||||
|
||||
PRBool NextSeg(QBezierCurve& TheSegment,eSegType& aCurveType);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsRenderingContextImpl */
|
||||
@@ -1,82 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsRepeater_h___
|
||||
#define nsRepeater_h___
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
class EventRecord;
|
||||
|
||||
class NS_WIDGET Repeater
|
||||
{
|
||||
public:
|
||||
|
||||
Repeater();
|
||||
virtual ~Repeater();
|
||||
|
||||
virtual void RepeatAction(const EventRecord &aMacEvent) {}
|
||||
virtual void IdleAction(const EventRecord &aMacEvent) {}
|
||||
|
||||
void StartRepeating();
|
||||
void StopRepeating();
|
||||
void StartIdling();
|
||||
void StopIdling();
|
||||
|
||||
static void DoRepeaters(const EventRecord &aMacEvent);
|
||||
static void DoIdlers(const EventRecord &aMacEvent);
|
||||
|
||||
protected:
|
||||
|
||||
void AddToRepeatList();
|
||||
void RemoveFromRepeatList();
|
||||
void AddToIdleList();
|
||||
void RemoveFromIdleList();
|
||||
|
||||
static Repeater* sRepeaters;
|
||||
static Repeater* sIdlers;
|
||||
|
||||
bool mRepeating;
|
||||
bool mIdling;
|
||||
Repeater* mPrevRptr;
|
||||
Repeater* mNextRptr;
|
||||
Repeater* mPrevIdlr;
|
||||
Repeater* mNextIdlr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef NSSIZE_H
|
||||
#define NSSIZE_H
|
||||
|
||||
#include "nsCoord.h"
|
||||
|
||||
// Maximum allowable size
|
||||
#define NS_MAXSIZE nscoord(1 << 30)
|
||||
|
||||
struct nsSize {
|
||||
nscoord width, height;
|
||||
|
||||
// Constructors
|
||||
nsSize() {}
|
||||
nsSize(const nsSize& aSize) {width = aSize.width; height = aSize.height;}
|
||||
nsSize(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
|
||||
|
||||
void SizeTo(nscoord aWidth, nscoord aHeight) {width = aWidth; height = aHeight;}
|
||||
void SizeBy(nscoord aDeltaWidth, nscoord aDeltaHeight) {width += aDeltaWidth;
|
||||
height += aDeltaHeight;}
|
||||
|
||||
// Overloaded operators. Note that '=' isn't defined so we'll get the
|
||||
// compiler generated default assignment operator
|
||||
PRBool operator==(const nsSize& aSize) const {
|
||||
return (PRBool) ((width == aSize.width) && (height == aSize.height));
|
||||
}
|
||||
PRBool operator!=(const nsSize& aSize) const {
|
||||
return (PRBool) ((width != aSize.width) || (height != aSize.height));
|
||||
}
|
||||
nsSize operator+(const nsSize& aSize) const {
|
||||
return nsSize(width + aSize.width, height + aSize.height);
|
||||
}
|
||||
nsSize operator-(const nsSize& aSize) const {
|
||||
return nsSize(width - aSize.width, height - aSize.height);
|
||||
}
|
||||
nsSize& operator+=(const nsSize& aSize) {width += aSize.width;
|
||||
height += aSize.height;
|
||||
return *this;}
|
||||
nsSize& operator-=(const nsSize& aSize) {width -= aSize.width;
|
||||
height -= aSize.height;
|
||||
return *this;}
|
||||
};
|
||||
|
||||
#endif /* NSSIZE_H */
|
||||
@@ -1,178 +0,0 @@
|
||||
// No appearance at all.
|
||||
#define NS_THEME_NONE 0
|
||||
|
||||
// A typical dialog button.
|
||||
#define NS_THEME_BUTTON 1
|
||||
|
||||
// A radio element within a radio group.
|
||||
#define NS_THEME_RADIO 2
|
||||
|
||||
// A checkbox element.
|
||||
#define NS_THEME_CHECKBOX 3
|
||||
|
||||
// The toolbox that contains the toolbars.
|
||||
#define NS_THEME_TOOLBOX 11
|
||||
|
||||
// A toolbar in an application window.
|
||||
#define NS_THEME_TOOLBAR 12
|
||||
|
||||
// A single toolbar button (with no associated dropdown)
|
||||
#define NS_THEME_TOOLBAR_BUTTON 13
|
||||
|
||||
// A dual toolbar button (e.g., a Back button with a dropdown)
|
||||
#define NS_THEME_TOOLBAR_DUAL_BUTTON 14
|
||||
|
||||
// The dropdown portion of a dual toolbar button
|
||||
#define NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN 15
|
||||
|
||||
// A separator. Can be horizontal or vertical.
|
||||
#define NS_THEME_TOOLBAR_SEPARATOR 16
|
||||
|
||||
// The gripper for a toolbar.
|
||||
#define NS_THEME_TOOLBAR_GRIPPER 17
|
||||
|
||||
// A status bar in a main application window.
|
||||
#define NS_THEME_STATUSBAR 21
|
||||
|
||||
// A single pane of a status bar.
|
||||
#define NS_THEME_STATUSBAR_PANEL 22
|
||||
|
||||
// The resizer background area in a status bar
|
||||
// for the resizer widget in the corner of a window.
|
||||
#define NS_THEME_STATUSBAR_RESIZER_PANEL 23
|
||||
|
||||
// The resizer itself.
|
||||
#define NS_THEME_RESIZER 24
|
||||
|
||||
// List boxes
|
||||
#define NS_THEME_LISTBOX 31
|
||||
|
||||
// A listbox item
|
||||
#define NS_THEME_LISTBOX_LISTITEM 32
|
||||
|
||||
// A tree widget
|
||||
#define NS_THEME_TREEVIEW 41
|
||||
|
||||
// A tree item
|
||||
#define NS_THEME_TREEVIEW_TREEITEM 42
|
||||
|
||||
// A tree widget twisty
|
||||
#define NS_THEME_TREEVIEW_TWISTY 43
|
||||
|
||||
// A tree widget branch line
|
||||
#define NS_THEME_TREEVIEW_LINE 44
|
||||
|
||||
// A listbox or tree widget header
|
||||
#define NS_THEME_TREEVIEW_HEADER 45
|
||||
|
||||
// An individual header cell
|
||||
#define NS_THEME_TREEVIEW_HEADER_CELL 46
|
||||
|
||||
// The sort arrow for a header.
|
||||
#define NS_THEME_TREEVIEW_HEADER_SORTARROW 47
|
||||
|
||||
// Open tree widget twisty
|
||||
#define NS_THEME_TREEVIEW_TWISTY_OPEN 48
|
||||
|
||||
// A horizontal progress bar.
|
||||
#define NS_THEME_PROGRESSBAR 51
|
||||
|
||||
// The progress bar's progress indicator
|
||||
#define NS_THEME_PROGRESSBAR_CHUNK 52
|
||||
|
||||
// A vertical progress bar.
|
||||
#define NS_THEME_PROGRESSBAR_VERTICAL 53
|
||||
|
||||
// A vertical progress chunk
|
||||
#define NS_THEME_PROGRESSBAR_CHUNK_VERTICAL 54
|
||||
|
||||
// A single tab in a tab widget.
|
||||
#define NS_THEME_TAB 61
|
||||
|
||||
// A single pane (inside the tabpanels container)
|
||||
#define NS_THEME_TAB_PANEL 62
|
||||
|
||||
// The tab just before the selection
|
||||
#define NS_THEME_TAB_LEFT_EDGE 63
|
||||
|
||||
// The tab just after the selection
|
||||
#define NS_THEME_TAB_RIGHT_EDGE 64
|
||||
|
||||
// The tab panels container.
|
||||
#define NS_THEME_TAB_PANELS 65
|
||||
|
||||
// A tooltip
|
||||
#define NS_THEME_TOOLTIP 71
|
||||
|
||||
// A spin control (up/down control for time/date pickers)
|
||||
#define NS_THEME_SPINNER 72
|
||||
|
||||
// The up button of a spin control
|
||||
#define NS_THEME_SPINNER_UP_BUTTON 73
|
||||
|
||||
// The down button of a spin control
|
||||
#define NS_THEME_SPINNER_DOWN_BUTTON 74
|
||||
|
||||
// A scrollbar.
|
||||
#define NS_THEME_SCROLLBAR 81
|
||||
|
||||
// A scrollbar button (up/down/left/right)
|
||||
#define NS_THEME_SCROLLBAR_BUTTON_UP 82
|
||||
#define NS_THEME_SCROLLBAR_BUTTON_DOWN 83
|
||||
#define NS_THEME_SCROLLBAR_BUTTON_LEFT 84
|
||||
#define NS_THEME_SCROLLBAR_BUTTON_RIGHT 85
|
||||
|
||||
// The scrollbar track
|
||||
#define NS_THEME_SCROLLBAR_TRACK_HORIZONTAL 86
|
||||
#define NS_THEME_SCROLLBAR_TRACK_VERTICAL 87
|
||||
|
||||
// The scrollbar thumb
|
||||
#define NS_THEME_SCROLLBAR_THUMB_HORIZONTAL 88
|
||||
#define NS_THEME_SCROLLBAR_THUMB_VERTICAL 89
|
||||
|
||||
// The gripper that goes on the thumb
|
||||
#define NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL 90
|
||||
#define NS_THEME_SCROLLBAR_GRIPPER_VERTICAL 91
|
||||
|
||||
// A textfield or text area
|
||||
#define NS_THEME_TEXTFIELD 95
|
||||
|
||||
// The caret of a text area
|
||||
#define NS_THEME_TEXTFIELD_CARET 96
|
||||
|
||||
// A dropdown list.
|
||||
#define NS_THEME_DROPDOWN 101
|
||||
|
||||
// The dropdown button(s) that open up a dropdown list.
|
||||
#define NS_THEME_DROPDOWN_BUTTON 102
|
||||
|
||||
// The text part of a dropdown list, to left of button
|
||||
#define NS_THEME_DROPDOWN_TEXT 103
|
||||
|
||||
// A slider
|
||||
#define NS_THEME_SLIDER 111
|
||||
|
||||
// A slider's thumb
|
||||
#define NS_THEME_SLIDER_THUMB 112
|
||||
|
||||
// If the platform supports it, the left/right chunks
|
||||
// of the slider thumb
|
||||
#define NS_THEME_SLIDER_THUMB_START 113
|
||||
#define NS_THEME_SLIDER_THUMB_END 114
|
||||
|
||||
// The ticks for a slider.
|
||||
#define NS_THEME_SLIDER_TICK 115
|
||||
|
||||
// A generic container that always repaints on state
|
||||
// changes. This is a hack to make checkboxes and
|
||||
// radio buttons work.
|
||||
#define NS_THEME_CHECKBOX_CONTAINER 200
|
||||
#define NS_THEME_RADIO_CONTAINER 201
|
||||
|
||||
// Window and dialog backgrounds
|
||||
#define NS_THEME_WINDOW 250
|
||||
#define NS_THEME_DIALOG 251
|
||||
|
||||
// Menu and Menu Bar backgrounds
|
||||
#define NS_THEME_MENU 260
|
||||
#define NS_THEME_MENUBAR 261
|
||||
@@ -1,256 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsTransform2D_h___
|
||||
#define nsTransform2D_h___
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsUnitConversion.h"
|
||||
|
||||
#define MG_2DIDENTITY 0
|
||||
#define MG_2DTRANSLATION 1
|
||||
#define MG_2DSCALE 2
|
||||
#define MG_2DGENERAL 4
|
||||
|
||||
class NS_GFX nsTransform2D
|
||||
{
|
||||
private:
|
||||
//accelerators
|
||||
|
||||
float m00, m01, m10, m11, m20, m21;
|
||||
PRUint16 type;
|
||||
|
||||
public:
|
||||
//constructors
|
||||
|
||||
nsTransform2D(void) { SetToIdentity(); }
|
||||
nsTransform2D(nsTransform2D *aTransform2D) { SetMatrix(aTransform2D); }
|
||||
|
||||
//destructor
|
||||
|
||||
~nsTransform2D(void) { }
|
||||
|
||||
/**
|
||||
* get the type of this transform
|
||||
*
|
||||
* @param
|
||||
* @return type from above set
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
PRUint16 GetType(void) { return type; }
|
||||
|
||||
/**
|
||||
* set this transform to identity
|
||||
*
|
||||
* @param
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void SetToIdentity(void) { m01 = m10 = m20 = m21 = 0.0f; m00 = m11 = 1.0f; type = MG_2DIDENTITY; }
|
||||
|
||||
/**
|
||||
* set this transform to a scale
|
||||
*
|
||||
* @param sx, x scale
|
||||
* @param sy, y scale
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void SetToScale(float sx, float sy);
|
||||
|
||||
/**
|
||||
* set this transform to a translation
|
||||
*
|
||||
* @param tx, x translation
|
||||
* @param ty, y translation
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void SetToTranslate(float tx, float ty);
|
||||
|
||||
/**
|
||||
* get the translation portion of this transform
|
||||
*
|
||||
* @param pt, Point to return translation values in
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void GetTranslation(float *ptX, float *ptY) { *ptX = m20; *ptY = m21; }
|
||||
void GetTranslationCoord(nscoord *ptX, nscoord *ptY) { *ptX = NSToCoordRound(m20); *ptY = NSToCoordRound(m21); }
|
||||
|
||||
/**
|
||||
* set the translation portion of this transform
|
||||
*
|
||||
* @param tx, x translation
|
||||
* @param ty, y translation
|
||||
* @exception
|
||||
**/
|
||||
|
||||
void SetTranslation(float tX, float tY) {
|
||||
m20 = tX;
|
||||
m21 = tY;
|
||||
type |= MG_2DTRANSLATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the X translation portion of this transform
|
||||
*
|
||||
* @param
|
||||
* @returns x component of translation
|
||||
* @exception
|
||||
**/
|
||||
|
||||
float GetXTranslation(void) { return m20; }
|
||||
nscoord GetXTranslationCoord(void) { return NSToCoordRound(m20); }
|
||||
|
||||
/**
|
||||
* get the Y translation portion of this transform
|
||||
*
|
||||
* @param
|
||||
* @returns y component of translation
|
||||
* @exception
|
||||
**/
|
||||
|
||||
float GetYTranslation(void) { return m21; }
|
||||
nscoord GetYTranslationCoord(void) { return NSToCoordRound(m21); }
|
||||
|
||||
/**
|
||||
* set this matrix and type from another Transform2D
|
||||
*
|
||||
* @param aTransform2D is the Transform2D to be copied from
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void SetMatrix(nsTransform2D *aTransform2D);
|
||||
|
||||
/**
|
||||
* post-multiply a new Transform
|
||||
*
|
||||
* @param newxform new Transform2D
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void Concatenate(nsTransform2D *newxform);
|
||||
|
||||
/**
|
||||
* pre-multiply a new Transform
|
||||
*
|
||||
* @param newxform new Transform2D
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void PreConcatenate(nsTransform2D *newxform);
|
||||
|
||||
/**
|
||||
* apply nontranslation portion of matrix to vector
|
||||
*
|
||||
* @param pt Point to transform
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void TransformNoXLate(float *ptX, float *ptY);
|
||||
void TransformNoXLateCoord(nscoord *ptX, nscoord *ptY);
|
||||
|
||||
/**
|
||||
* apply matrix to vector
|
||||
*
|
||||
* @param pt Point to transform
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void Transform(float *ptX, float *ptY);
|
||||
void TransformCoord(nscoord *ptX, nscoord *ptY);
|
||||
|
||||
/**
|
||||
* apply matrix to rect
|
||||
*
|
||||
* @param rect Rect to transform
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void Transform(float *aX, float *aY, float *aWidth, float *aHeight);
|
||||
void TransformCoord(nscoord *aX, nscoord *aY, nscoord *aWidth, nscoord *aHeight);
|
||||
|
||||
/**
|
||||
* Scale an array of X/Y coordinates by the X/Y scale factor in the
|
||||
* matrix. The scale is done as if the other coordinate were zero.
|
||||
*
|
||||
* @param aSrc Base of coordinate input array
|
||||
* @param aDst Base of coordinate output array
|
||||
* @param aNumCoords Number of coordinates to scale
|
||||
*/
|
||||
void ScaleXCoords(const nscoord* aSrc, PRUint32 aNumCoords, PRIntn* aDst);
|
||||
void ScaleYCoords(const nscoord* aSrc, PRUint32 aNumCoords, PRIntn* aDst);
|
||||
|
||||
/**
|
||||
* add a translation to a Transform via x, y pair
|
||||
*
|
||||
* @param ptX x value to add as x translation
|
||||
* @param ptY y value to add as y translation
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void AddTranslation(float ptX, float ptY);
|
||||
|
||||
/**
|
||||
* add a scale to a Transform via x, y pair
|
||||
*
|
||||
* @param ptX x value to add as x scale
|
||||
* @param ptY y value to add as y scale
|
||||
* @exception
|
||||
* @author michaelp 09-25-97 1:56pm
|
||||
**/
|
||||
|
||||
void AddScale(float ptX, float ptY);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,2 +0,0 @@
|
||||
icon_0.gif
|
||||
icon_1.gif
|
||||
@@ -1,139 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx
|
||||
EXPORTS = nsFontList.h
|
||||
LIBRARY_NAME = gkgfx
|
||||
EXPORT_LIBRARY = 1
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
widget \
|
||||
locale \
|
||||
view \
|
||||
pref \
|
||||
gfx2 \
|
||||
imglib2 \
|
||||
uconv \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter os2 windows,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS =
|
||||
else
|
||||
DIRS = ps
|
||||
endif
|
||||
|
||||
ifneq (,$(filter beos os2 mac windows,$(MOZ_GFX_TOOLKIT)))
|
||||
DIRS += $(MOZ_GFX_TOOLKIT)
|
||||
endif
|
||||
|
||||
# Build xlibrgb only for X toolkits and/or Xprint
|
||||
ifneq (,$(filter xlib,$(MOZ_WIDGET_TOOLKIT))$(MOZ_ENABLE_XLIB)$(MOZ_ENABLE_XPRINT))
|
||||
DIRS += xlibrgb
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GTK
|
||||
DIRS += gtk
|
||||
endif
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
DIRS += gtk
|
||||
endif
|
||||
ifdef MOZ_ENABLE_QT
|
||||
DIRS += qt
|
||||
endif
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
DIRS += xlib
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XPRINT
|
||||
DIRS += xprint
|
||||
endif
|
||||
|
||||
CPPSRCS = \
|
||||
nsBlender.cpp \
|
||||
nsColor.cpp \
|
||||
nsColorNames.cpp \
|
||||
nsDeviceContext.cpp \
|
||||
nsFont.cpp \
|
||||
nsFontList.cpp \
|
||||
nsRenderingContextImpl.cpp \
|
||||
nsRect.cpp \
|
||||
nsTransform2D.cpp \
|
||||
nsScriptableRegion.cpp \
|
||||
nsGraphicsImpl.cpp \
|
||||
nsPrintOptionsImpl.cpp \
|
||||
nsPrintSettingsImpl.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += nsCompressedCharMap.cpp
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gtk gtk2 xlib os2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += \
|
||||
nsRegion.cpp \
|
||||
nsRegionImpl.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gtk gtk2 xlib beos,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += imgScaler.cpp
|
||||
endif
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS += \
|
||||
mac/nsRegionPool.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)mozutil_s.$(LIB_SUFFIX) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFX
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DEFINES += -DWIN32_LEAN_AND_MEAN
|
||||
endif
|
||||
|
||||
libs:: icon_0.gif icon_1.gif
|
||||
$(INSTALL) -m 555 $^ $(DIST)/bin/res/gfx
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = gfx
|
||||
LIBRARY_NAME = gfx_beos
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxBeOSModule
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextBeOS.cpp \
|
||||
nsDeviceContextSpecFactoryB.cpp \
|
||||
nsDeviceContextSpecB.cpp \
|
||||
nsDrawingSurfaceBeOS.cpp \
|
||||
nsFontMetricsBeOS.cpp \
|
||||
nsGfxFactoryBeOS.cpp \
|
||||
nsGraphicsStateBeOS.cpp \
|
||||
nsRenderingContextBeOS.cpp \
|
||||
nsImageBeOS.cpp \
|
||||
nsRegionBeOS.cpp \
|
||||
nsScreenBeOS.cpp \
|
||||
nsScreenManagerBeOS.cpp \
|
||||
nsPrintOptionsBeOS.cpp \
|
||||
$(NULL)
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
pref \
|
||||
widget \
|
||||
view \
|
||||
intl \
|
||||
uconv \
|
||||
dom \
|
||||
windowwatcher \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXONXP
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
INCLUDES += $(TK_CFLAGS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(MOZ_JS_LIBS) \
|
||||
-lgkgfx \
|
||||
$(XPCOM_LIBS) \
|
||||
$(TK_LIBS) \
|
||||
$(NSPR_LIBS)
|
||||
|
||||
INCLUDES += \
|
||||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
$(NULL)
|
||||
@@ -1,472 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsDeviceContextBeOS.h"
|
||||
#include "nsFontMetricsBeOS.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
#include "nsGfxPSCID.h"
|
||||
#include "nsIDeviceContextPS.h"
|
||||
|
||||
#include <ScrollBar.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include "nsIScreenManager.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
nscoord nsDeviceContextBeOS::mDpi = 96;
|
||||
|
||||
nsDeviceContextBeOS::nsDeviceContextBeOS()
|
||||
: DeviceContextImpl()
|
||||
{
|
||||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mDepth = 0 ;
|
||||
mNumCells = 0;
|
||||
|
||||
mWidthFloat = 0.0f;
|
||||
mHeightFloat = 0.0f;
|
||||
mWidth = -1;
|
||||
mHeight = -1;
|
||||
}
|
||||
|
||||
nsDeviceContextBeOS::~nsDeviceContextBeOS()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->UnregisterCallback("browser.display.screen_resolution",
|
||||
prefChanged, (void *)this);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::Init(nsNativeWidget aNativeWidget)
|
||||
{
|
||||
// get the screen object and its width/height
|
||||
// XXXRight now this will only get the primary monitor.
|
||||
|
||||
nsresult ignore;
|
||||
nsCOMPtr<nsIScreenManager> sm ( do_GetService("@mozilla.org/gfx/screenmanager;1", &ignore) );
|
||||
if ( sm ) {
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
sm->GetPrimaryScreen ( getter_AddRefs(screen) );
|
||||
if ( screen ) {
|
||||
PRInt32 x, y, width, height, depth;
|
||||
screen->GetAvailRect ( &x, &y, &width, &height );
|
||||
screen->GetPixelDepth ( &depth );
|
||||
mWidthFloat = float(width);
|
||||
mHeightFloat = float(height);
|
||||
mDepth = NS_STATIC_CAST ( PRUint32, depth );
|
||||
}
|
||||
}
|
||||
|
||||
static int initialized = 0;
|
||||
if (!initialized) {
|
||||
initialized = 1;
|
||||
|
||||
// Set prefVal the value of the preference "browser.display.screen_resolution"
|
||||
// or -1 if we can't get it.
|
||||
// If it's negative, we pretend it's not set.
|
||||
// If it's 0, it means force use of the operating system's logical resolution.
|
||||
// If it's positive, we use it as the logical resolution
|
||||
PRInt32 prefVal = -1;
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &res));
|
||||
if (NS_SUCCEEDED(res) && prefs) {
|
||||
res = prefs->GetIntPref("browser.display.screen_resolution", &prefVal);
|
||||
if (! NS_SUCCEEDED(res)) {
|
||||
prefVal = -1;
|
||||
}
|
||||
prefs->RegisterCallback("browser.display.screen_resolution", prefChanged,
|
||||
(void *)this);
|
||||
}
|
||||
|
||||
// Set OSVal to what the operating system thinks the logical resolution is.
|
||||
PRInt32 OSVal = 72;
|
||||
|
||||
if (prefVal > 0) {
|
||||
// If there's a valid pref value for the logical resolution,
|
||||
// use it.
|
||||
mDpi = prefVal;
|
||||
} else if ((prefVal == 0) || (OSVal > 96)) {
|
||||
// Either if the pref is 0 (force use of OS value) or the OS
|
||||
// value is bigger than 96, use the OS value.
|
||||
mDpi = OSVal;
|
||||
} else {
|
||||
// if we couldn't get the pref or it's negative, and the OS
|
||||
// value is under 96ppi, then use 96.
|
||||
mDpi = 96;
|
||||
}
|
||||
}
|
||||
|
||||
SetDPI(mDpi);
|
||||
|
||||
mScrollbarHeight = PRInt16(B_H_SCROLL_BAR_HEIGHT);
|
||||
mScrollbarWidth = PRInt16(B_V_SCROLL_BAR_WIDTH);
|
||||
|
||||
#ifdef DEBUG
|
||||
static PRBool once = PR_TRUE;
|
||||
if (once) {
|
||||
printf("GFX: dpi=%d t2p=%g p2t=%g depth=%d\n", mDpi, mTwipsToPixels, mPixelsToTwips,mDepth);
|
||||
once = PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::CreateRenderingContext(nsIRenderingContext *&aContext)
|
||||
{
|
||||
nsIRenderingContext *pContext;
|
||||
nsresult rv;
|
||||
nsDrawingSurfaceBeOS *surf;
|
||||
BView *w;
|
||||
|
||||
w = (BView*)mWidget;
|
||||
|
||||
// to call init for this, we need to have a valid nsDrawingSurfaceBeOS created
|
||||
pContext = new nsRenderingContextBeOS();
|
||||
|
||||
if (nsnull != pContext)
|
||||
{
|
||||
NS_ADDREF(pContext);
|
||||
|
||||
// create the nsDrawingSurfaceBeOS
|
||||
surf = new nsDrawingSurfaceBeOS();
|
||||
|
||||
if (surf && w)
|
||||
{
|
||||
|
||||
// init the nsDrawingSurfaceBeOS
|
||||
rv = surf->Init(w);
|
||||
|
||||
if (NS_OK == rv)
|
||||
// Init the nsRenderingContextBeOS
|
||||
rv = pContext->Init(this, surf);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_OK != rv)
|
||||
{
|
||||
NS_IF_RELEASE(pContext);
|
||||
}
|
||||
|
||||
aContext = pContext;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::SupportsNativeWidgets(PRBool &aSupportsWidgets)
|
||||
{
|
||||
//XXX it is very critical that this not lie!! MMP
|
||||
// read the comments in the mac code for this
|
||||
aSupportsWidgets = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetScrollBarDimensions(float &aWidth, float &aHeight) const
|
||||
{
|
||||
aWidth = mScrollbarWidth * mPixelsToTwips;
|
||||
aHeight = mScrollbarHeight * mPixelsToTwips;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
switch (aID) {
|
||||
case eSystemFont_Caption: // css2
|
||||
case eSystemFont_Icon :
|
||||
case eSystemFont_Menu :
|
||||
case eSystemFont_MessageBox :
|
||||
case eSystemFont_SmallCaption :
|
||||
case eSystemFont_StatusBar :
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document:
|
||||
case eSystemFont_Workspace:
|
||||
case eSystemFont_Desktop:
|
||||
case eSystemFont_Info:
|
||||
case eSystemFont_Dialog:
|
||||
case eSystemFont_Button:
|
||||
case eSystemFont_PullDownMenu:
|
||||
case eSystemFont_List:
|
||||
case eSystemFont_Field:
|
||||
case eSystemFont_Tooltips: // moz
|
||||
case eSystemFont_Widget:
|
||||
status = GetSystemFontInfo(be_plain_font, aID, aFont);
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetDrawingSurface(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface &aSurface)
|
||||
{
|
||||
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
|
||||
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::ConvertPixel(nscolor aColor,
|
||||
PRUint32 & aPixel)
|
||||
{
|
||||
// koehler@mythrium.com:
|
||||
// I think this fill the 32 bits pixel with the desired color
|
||||
// It's possible that the nscolor is not representing that color
|
||||
// if you just dump it inside a 32 bits value.
|
||||
aPixel = aColor;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
return nsFontMetricsBeOS::FamilyExists(aFontName);
|
||||
}
|
||||
|
||||
/*
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::CheckFontExistence(const nsString& aFontName)
|
||||
{
|
||||
PRBool isthere = PR_FALSE;
|
||||
|
||||
char* cStr = ToNewCString(aFontName);
|
||||
|
||||
int32 numFamilies = count_font_families();
|
||||
for(int32 i = 0; i < numFamilies; i++)
|
||||
{
|
||||
font_family family;
|
||||
uint32 flags;
|
||||
if(get_font_family(i, &family, &flags) == B_OK)
|
||||
{
|
||||
if(strcmp(family, cStr) == 0)
|
||||
{
|
||||
isthere = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("%s there? %s\n", cStr, isthere?"Yes":"No" );
|
||||
|
||||
delete[] cStr;
|
||||
|
||||
if (PR_TRUE == isthere)
|
||||
return NS_OK;
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*/
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
|
||||
{
|
||||
if (mWidth == -1)
|
||||
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
|
||||
|
||||
if (mHeight == -1)
|
||||
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
|
||||
|
||||
aWidth = mWidth;
|
||||
aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetRect(nsRect &aRect)
|
||||
{
|
||||
PRInt32 width, height;
|
||||
nsresult rv;
|
||||
rv = GetDeviceSurfaceDimensions(width, height);
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = width;
|
||||
aRect.height = height;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetClientRect(nsRect &aRect)
|
||||
{
|
||||
//XXX do we know if the client rect should ever differ from the screen rect?
|
||||
return GetRect ( aRect );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext)
|
||||
{
|
||||
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
|
||||
|
||||
// Create a Postscript device context
|
||||
nsresult rv;
|
||||
nsIDeviceContextPS *dcps;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kCDeviceContextPS,
|
||||
nsnull,
|
||||
NS_GET_IID(nsIDeviceContextPS),
|
||||
(void **)&dcps);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context");
|
||||
|
||||
dcps->SetSpec(aDevice);
|
||||
dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
|
||||
(nsIDeviceContext*)this);
|
||||
|
||||
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
|
||||
(void **)&aContext);
|
||||
|
||||
NS_RELEASE(dcps);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::EndDocument(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::BeginPage(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::EndPage(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
aDepth = mDepth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextBeOS::SetDPI(PRInt32 aDpi)
|
||||
{
|
||||
mDpi = aDpi;
|
||||
|
||||
int pt2t = 72;
|
||||
|
||||
// make p2t a nice round number - this prevents rounding problems
|
||||
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(aDpi)));
|
||||
mTwipsToPixels = 1.0f / mPixelsToTwips;
|
||||
|
||||
// XXX need to reflow all documents
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int nsDeviceContextBeOS::prefChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsDeviceContextBeOS *context = (nsDeviceContextBeOS*)aClosure;
|
||||
nsresult rv;
|
||||
|
||||
if (nsCRT::strcmp(aPref, "browser.display.screen_resolution")==0) {
|
||||
PRInt32 dpi;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
|
||||
rv = prefs->GetIntPref(aPref, &dpi);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
context->SetDPI(dpi);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDeviceContextBeOS::GetSystemFontInfo(const BFont *theFont, nsSystemFontID anID, nsFont* aFont) const
|
||||
{
|
||||
nsresult status = NS_OK;
|
||||
|
||||
aFont->style = NS_FONT_STYLE_NORMAL;
|
||||
aFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
|
||||
// do we have the default_font defined by BeOS, if not then
|
||||
// we error out.
|
||||
if( !theFont )
|
||||
theFont = be_plain_font; // BeOS default font
|
||||
|
||||
if( !theFont )
|
||||
{
|
||||
status = NS_ERROR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
font_family family;
|
||||
font_style style;
|
||||
font_height height;
|
||||
|
||||
theFont->GetFamilyAndStyle(&family, &style);
|
||||
aFont->name.AssignWithConversion( family );
|
||||
|
||||
// No weight
|
||||
|
||||
theFont->GetHeight(&height);
|
||||
aFont->size = NSIntPixelsToTwips(uint32(height.ascent+height.descent+height.leading), mPixelsToTwips);
|
||||
|
||||
// no style
|
||||
|
||||
// no decoration
|
||||
|
||||
status = NS_OK;
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDeviceContextBeOS_h___
|
||||
#define nsDeviceContextBeOS_h___
|
||||
|
||||
#include "nsDeviceContext.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
||||
#include "nsRenderingContextBeOS.h"
|
||||
|
||||
class nsDeviceContextBeOS : public DeviceContextImpl
|
||||
{
|
||||
public:
|
||||
nsDeviceContextBeOS();
|
||||
virtual ~nsDeviceContextBeOS();
|
||||
|
||||
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aView,aContext));}
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext) {return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));}
|
||||
|
||||
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
|
||||
|
||||
NS_IMETHOD GetScrollBarDimensions(float &aWidth, float &aHeight) const;
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
|
||||
//get a low level drawing surface for rendering. the rendering context
|
||||
//that is passed in is used to create the drawing surface if there isn't
|
||||
//already one in the device context. the drawing surface is then cached
|
||||
//in the device context for re-use.
|
||||
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
NS_IMETHOD GetClientRect(nsRect &aRect);
|
||||
NS_IMETHOD GetRect(nsRect &aRect);
|
||||
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
NS_IMETHOD EndPage(void);
|
||||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
static int prefChanged(const char *aPref, void *aClosure);
|
||||
nsresult SetDPI(PRInt32 dpi);
|
||||
|
||||
private:
|
||||
PRUint32 mDepth;
|
||||
PRBool mWriteable;
|
||||
PRUint32 mNumCells;
|
||||
PRInt16 mScrollbarHeight;
|
||||
PRInt16 mScrollbarWidth;
|
||||
static nscoord mDpi;
|
||||
|
||||
float mWidthFloat;
|
||||
float mHeightFloat;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
|
||||
nsresult GetSystemFontInfo(const BFont *font, nsSystemFontID anID, nsFont* aFont) const;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextBeOS_h___ */
|
||||
|
||||
@@ -1,629 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDeviceContextSpecB.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
|
||||
// The PrinterEnumerator creates the printer info
|
||||
// but the nsDeviceContextSpecG cleans it up
|
||||
// If it gets created (via the Page Setup Dialog) but the user never prints anything
|
||||
// then it will never be delete, so this class takes care of that.
|
||||
class GlobalPrinters {
|
||||
public:
|
||||
static GlobalPrinters* GetInstance() { return &mGlobalPrinters; }
|
||||
~GlobalPrinters() { FreeGlobalPrinters(); }
|
||||
|
||||
void FreeGlobalPrinters();
|
||||
nsresult InitializeGlobalPrinters();
|
||||
|
||||
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
|
||||
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
|
||||
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
|
||||
|
||||
protected:
|
||||
GlobalPrinters() {}
|
||||
|
||||
static GlobalPrinters mGlobalPrinters;
|
||||
static nsStringArray* mGlobalPrinterList;
|
||||
static int mGlobalNumPrinters;
|
||||
|
||||
};
|
||||
//---------------
|
||||
// static members
|
||||
GlobalPrinters GlobalPrinters::mGlobalPrinters;
|
||||
nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull;
|
||||
int GlobalPrinters::mGlobalNumPrinters = 0;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecBeOS
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
nsDeviceContextSpecBeOS :: nsDeviceContextSpecBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Destroy the nsDeviceContextSpecBeOS
|
||||
* @update dc 2/15/98
|
||||
*/
|
||||
nsDeviceContextSpecBeOS :: ~nsDeviceContextSpecBeOS()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID);
|
||||
|
||||
#if 0
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecBeOS, nsIDeviceContextSpec)
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (nsnull == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(kIDeviceContextSpecIID))
|
||||
{
|
||||
nsIDeviceContextSpec* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIDeviceContextSpecPSIID))
|
||||
{
|
||||
nsIDeviceContextSpecPS* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
nsIDeviceContextSpec* tmp = this;
|
||||
nsISupports* tmp2 = tmp;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecBeOS)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecBeOS)
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
*/
|
||||
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
||||
const char* aChromeURL,
|
||||
PRBool& aClickedOK)
|
||||
{
|
||||
NS_ASSERTION(aPS, "Must have a print settings!");
|
||||
|
||||
aClickedOK = PR_FALSE;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if (!array) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> ps = aPS;
|
||||
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
|
||||
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
|
||||
array->AppendElement(psSupports);
|
||||
|
||||
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
|
||||
if (ioParamBlock) {
|
||||
ioParamBlock->SetInt(0, 0);
|
||||
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
|
||||
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
|
||||
|
||||
array->AppendElement(blkSupps);
|
||||
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
|
||||
NS_ASSERTION(array, "array must be a supports");
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch) {
|
||||
nsCOMPtr<nsIDOMWindow> active;
|
||||
wwatch->GetActiveWindow(getter_AddRefs(active));
|
||||
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = wwatch->OpenWindow(parent, aChromeURL,
|
||||
"_blank", "chrome,modal,centerscreen", array,
|
||||
getter_AddRefs(newWindow));
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 buttonPressed = 0;
|
||||
ioParamBlock->GetInt(0, &buttonPressed);
|
||||
if (buttonPressed == 1) {
|
||||
aClickedOK = PR_TRUE;
|
||||
} else {
|
||||
rv = NS_ERROR_ABORT;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_ABORT;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the nsDeviceContextSpecBeOS
|
||||
* @update dc 2/15/98
|
||||
* @update syd 3/2/99
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_ASSERTION(nsnull != aPS, "No print settings.");
|
||||
|
||||
// if there is a current selection then enable the "Selection" radio button
|
||||
if (aPS != nsnull) {
|
||||
PRBool isOn;
|
||||
aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
|
||||
}
|
||||
}
|
||||
|
||||
char *path;
|
||||
PRBool canPrint = PR_FALSE;
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 paper_size = NS_LETTER_SIZE;
|
||||
PRInt32 orientation = NS_PORTRAIT;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!aQuiet ) {
|
||||
rv = DisplayXPDialog(aPS,
|
||||
"chrome://global/content/printdialog.xul", canPrint);
|
||||
}
|
||||
else {
|
||||
canPrint = PR_TRUE;
|
||||
}
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
if (canPrint) {
|
||||
if (aPS != nsnull) {
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperSize(&paper_size);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
|
||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
}
|
||||
if (printer != nsnull)
|
||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||
#ifdef DEBUG_rods
|
||||
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
|
||||
printf("printRange %d\n", printRange);
|
||||
printf("fromPage %d\n", fromPage);
|
||||
printf("toPage %d\n", toPage);
|
||||
#endif /* DEBUG_rods */
|
||||
} else {
|
||||
#ifdef VMS
|
||||
// Note to whoever puts the "lpr" into the prefs file. Please contact me
|
||||
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
|
||||
strcpy(mPrData.command, "print");
|
||||
#else
|
||||
strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
|
||||
#endif /* VMS */
|
||||
}
|
||||
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.orientation = orientation;
|
||||
mPrData.toPrinter = !tofile;
|
||||
mPrData.copies = copies;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
if (!printfile) {
|
||||
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
|
||||
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
|
||||
strcpy(mPrData.path, "mozilla.ps");
|
||||
|
||||
if ( path != (char *) nsnull )
|
||||
sprintf(mPrData.path, "%s/mozilla.ps", path);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NOT_IMPLEMENTED_YET
|
||||
if (mGlobalNumPrinters) {
|
||||
for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
|
||||
if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1)))
|
||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||
}
|
||||
}
|
||||
#endif /* NOT_IMPLEMENTED_YET */
|
||||
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetToPrinter( PRBool &aToPrinter )
|
||||
{
|
||||
aToPrinter = mPrData.toPrinter;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetPrinterName ( char **aPrinter )
|
||||
{
|
||||
*aPrinter = &mPrData.printer[0];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetCopies ( int &aCopies )
|
||||
{
|
||||
aCopies = mPrData.copies;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetFirstPageFirst ( PRBool &aFpf )
|
||||
{
|
||||
aFpf = mPrData.fpf;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetGrayscale ( PRBool &aGrayscale )
|
||||
{
|
||||
aGrayscale = mPrData.grayscale;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetSize ( int &aSize )
|
||||
{
|
||||
aSize = mPrData.size;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetPageDimensions ( float &aWidth, float &aHeight )
|
||||
{
|
||||
if ( mPrData.size == NS_LETTER_SIZE ) {
|
||||
aWidth = 8.5;
|
||||
aHeight = 11.0;
|
||||
} else if ( mPrData.size == NS_LEGAL_SIZE ) {
|
||||
aWidth = 8.5;
|
||||
aHeight = 14.0;
|
||||
} else if ( mPrData.size == NS_EXECUTIVE_SIZE ) {
|
||||
aWidth = 7.5;
|
||||
aHeight = 10.0;
|
||||
} else if ( mPrData.size == NS_A4_SIZE ) {
|
||||
// 210mm X 297mm == 8.27in X 11.69in
|
||||
aWidth = 8.27;
|
||||
aHeight = 11.69;
|
||||
} else if ( mPrData.size == NS_A3_SIZE ) {
|
||||
// 297mm X 420mm == 11.69in X 16.53in
|
||||
aWidth = 11.69;
|
||||
aHeight = 16.53;
|
||||
}
|
||||
|
||||
if (mPrData.orientation == NS_LANDSCAPE) {
|
||||
float temp;
|
||||
temp = aWidth;
|
||||
aWidth = aHeight;
|
||||
aHeight = temp;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetLandscape ( PRBool &landscape )
|
||||
{
|
||||
landscape = (mPrData.orientation == NS_LANDSCAPE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetTopMargin ( float &value )
|
||||
{
|
||||
value = mPrData.top;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetBottomMargin ( float &value )
|
||||
{
|
||||
value = mPrData.bottom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetRightMargin ( float &value )
|
||||
{
|
||||
value = mPrData.right;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetLeftMargin ( float &value )
|
||||
{
|
||||
value = mPrData.left;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetCommand ( char **aCommand )
|
||||
{
|
||||
*aCommand = &mPrData.command[0];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetPath ( char **aPath )
|
||||
{
|
||||
*aPath = &mPrData.path[0];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: GetUserCancelled( PRBool &aCancel )
|
||||
{
|
||||
aCancel = mPrData.cancel;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Closes the printmanager if it is open.
|
||||
* @update dc 2/15/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS :: ClosePrintManager()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Printer Enumerator
|
||||
nsPrinterEnumeratorBeOS::nsPrinterEnumeratorBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorBeOS, nsIPrinterEnumerator)
|
||||
|
||||
NS_IMETHODIMP nsPrinterEnumeratorBeOS::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
|
||||
{
|
||||
NS_ENSURE_ARG(aCount);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
if (aCount)
|
||||
*aCount = 0;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aResult)
|
||||
*aResult = nsnull;
|
||||
else
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
|
||||
if (!array && numPrinters > 0) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
while( count < numPrinters )
|
||||
{
|
||||
|
||||
PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
|
||||
|
||||
if (!str) {
|
||||
for (int i = count - 1; i >= 0; i--)
|
||||
nsMemory::Free(array[i]);
|
||||
|
||||
nsMemory::Free(array);
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
array[count++] = str;
|
||||
|
||||
}
|
||||
*aCount = count;
|
||||
*aResult = array;
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPrinterEnumeratorBeOS::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
|
||||
{
|
||||
/* fixme: We simply ignore the |aPrinter| argument here
|
||||
* We should get the supported printer attributes from the printer and
|
||||
* populate the print job options dialog with these data instead of using
|
||||
* the "default set" here.
|
||||
* However, this requires changes on all platforms and is another big chunk
|
||||
* of patches ... ;-(
|
||||
*/
|
||||
|
||||
PRBool pressedOK;
|
||||
return DisplayXPDialog(aPrintSettings,
|
||||
"chrome://global/content/printjoboptions.xul",
|
||||
pressedOK);
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
nsresult GlobalPrinters::InitializeGlobalPrinters ()
|
||||
{
|
||||
if (PrintersAreAllocated()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mGlobalNumPrinters = 0;
|
||||
mGlobalPrinterList = new nsStringArray();
|
||||
if (!mGlobalPrinterList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
/* add an entry for the default printer (see nsPostScriptObj.cpp) */
|
||||
mGlobalPrinterList->AppendString(
|
||||
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default")));
|
||||
mGlobalNumPrinters++;
|
||||
|
||||
/* get the list of printers */
|
||||
char *printerList = nsnull;
|
||||
|
||||
/* the env var MOZILLA_PRINTER_LIST can "override" the prefs */
|
||||
printerList = PR_GetEnv("MOZILLA_PRINTER_LIST");
|
||||
|
||||
if (!printerList) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void) pPrefs->CopyCharPref("print.printer_list", &printerList);
|
||||
}
|
||||
}
|
||||
|
||||
if (printerList) {
|
||||
char *tok_lasts;
|
||||
char *name;
|
||||
|
||||
/* PL_strtok_r() will modify the string - copy it! */
|
||||
printerList = strdup(printerList);
|
||||
if (!printerList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for( name = PL_strtok_r(printerList, " ", &tok_lasts) ;
|
||||
name != nsnull ;
|
||||
name = PL_strtok_r(nsnull, " ", &tok_lasts) )
|
||||
{
|
||||
mGlobalPrinterList->AppendString(
|
||||
nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME)) +
|
||||
nsString(NS_ConvertASCIItoUCS2(name)));
|
||||
mGlobalNumPrinters++;
|
||||
}
|
||||
|
||||
free(printerList);
|
||||
}
|
||||
|
||||
if (mGlobalNumPrinters == 0)
|
||||
return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAILABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void GlobalPrinters::FreeGlobalPrinters()
|
||||
{
|
||||
delete mGlobalPrinterList;
|
||||
mGlobalPrinterList = nsnull;
|
||||
mGlobalNumPrinters = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDeviceContextSpecB_h___
|
||||
#define nsDeviceContextSpecB_h___
|
||||
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "nsDeviceContextSpecB.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIDeviceContextSpecPS.h"
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
|
||||
#include "nsPrintdBeOS.h"
|
||||
|
||||
class nsDeviceContextSpecBeOS : public nsIDeviceContextSpec ,
|
||||
public nsIDeviceContextSpecPS
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
nsDeviceContextSpecBeOS();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/**
|
||||
* Initialize the nsDeviceContextSpecBeOS for use. This will allocate a printrecord for use
|
||||
* @update dc 2/16/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
|
||||
|
||||
/**
|
||||
* Closes the printmanager if it is open.
|
||||
* @update dc 2/13/98
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD GetToPrinter( PRBool &aToPrinter );
|
||||
|
||||
NS_IMETHOD GetPrinterName ( char **aPrinter );
|
||||
|
||||
NS_IMETHOD GetCopies ( int &aCopies );
|
||||
|
||||
NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );
|
||||
|
||||
NS_IMETHOD GetGrayscale( PRBool &aGrayscale );
|
||||
|
||||
NS_IMETHOD GetSize ( int &aSize );
|
||||
|
||||
NS_IMETHOD GetTopMargin ( float &value );
|
||||
|
||||
NS_IMETHOD GetBottomMargin ( float &value );
|
||||
|
||||
NS_IMETHOD GetLeftMargin ( float &value );
|
||||
|
||||
NS_IMETHOD GetRightMargin ( float &value );
|
||||
|
||||
NS_IMETHOD GetCommand ( char **aCommand );
|
||||
|
||||
NS_IMETHOD GetPath ( char **aPath );
|
||||
|
||||
NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight );
|
||||
|
||||
NS_IMETHOD GetLandscape (PRBool &aLandscape);
|
||||
|
||||
NS_IMETHOD GetUserCancelled( PRBool &aCancel );
|
||||
|
||||
/**
|
||||
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecBeOS();
|
||||
|
||||
public:
|
||||
int InitializeGlobalPrinters();
|
||||
void FreeGlobalPrinters();
|
||||
|
||||
protected:
|
||||
BeOSPrData mPrData;
|
||||
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Printer Enumerator
|
||||
//-------------------------------------------------------------------------
|
||||
class nsPrinterEnumeratorBeOS : public nsIPrinterEnumerator
|
||||
{
|
||||
public:
|
||||
nsPrinterEnumeratorBeOS();
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRINTERENUMERATOR
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDeviceContextSpecFactoryB.h"
|
||||
#include "nsDeviceContextSpecB.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Constructor
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
nsDeviceContextSpecFactoryBeOS :: nsDeviceContextSpecFactoryBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Destructor
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
nsDeviceContextSpecFactoryBeOS :: ~nsDeviceContextSpecFactoryBeOS()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryBeOS, nsIDeviceContextSpecFactory)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the device context spec factory
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Get a device context specification
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
NS_ADDREF(aNewSpec);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDeviceContextSpecFactoryB_h___
|
||||
#define nsDeviceContextSpecFactoryB_h___
|
||||
|
||||
#include "nsIDeviceContextSpecFactory.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
|
||||
class nsDeviceContextSpecFactoryBeOS : public nsIDeviceContextSpecFactory
|
||||
{
|
||||
public:
|
||||
nsDeviceContextSpecFactoryBeOS();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(void);
|
||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryBeOS();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,277 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (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.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDrawingSurfaceBeOS.h"
|
||||
#include "nsCoord.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsDrawingSurfaceBeOS, nsIDrawingSurface, nsIDrawingSurfaceBeOS)
|
||||
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
static PRTime mLockTime, mUnlockTime;
|
||||
#endif
|
||||
|
||||
nsDrawingSurfaceBeOS :: nsDrawingSurfaceBeOS()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mView = NULL;
|
||||
|
||||
mBitmap = nsnull;
|
||||
mWidth = 0;
|
||||
mHeight = 0;
|
||||
|
||||
mLockWidth = 0;
|
||||
mLockHeight = 0;
|
||||
mLockFlags = 0;
|
||||
mLockX = 0;
|
||||
mLockY = 0;
|
||||
mLocked = PR_FALSE;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceBeOS :: ~nsDrawingSurfaceBeOS()
|
||||
{
|
||||
if(mBitmap)
|
||||
{
|
||||
mBitmap->RemoveChild(mView);
|
||||
delete mBitmap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock a rect of a drawing surface and return a
|
||||
* pointer to the upper left hand corner of the
|
||||
* bitmap.
|
||||
* @param aX x position of subrect of bitmap
|
||||
* @param aY y position of subrect of bitmap
|
||||
* @param aWidth width of subrect of bitmap
|
||||
* @param aHeight height of subrect of bitmap
|
||||
* @param aBits out parameter for upper left hand
|
||||
* corner of bitmap
|
||||
* @param aStride out parameter for number of bytes
|
||||
* to add to aBits to go from scanline to scanline
|
||||
* @param aWidthBytes out parameter for number of
|
||||
* bytes per line in aBits to process aWidth pixels
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
mLockTime = PR_Now();
|
||||
// MOZ_TIMER_RESET(mLockTime);
|
||||
// MOZ_TIMER_START(mLockTime);
|
||||
#endif
|
||||
|
||||
if (mLocked)
|
||||
{
|
||||
NS_ASSERTION(0, "nested lock attempt");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mLocked = PR_TRUE;
|
||||
|
||||
mLockX = aX;
|
||||
mLockY = aY;
|
||||
mLockWidth = aWidth;
|
||||
mLockHeight = aHeight;
|
||||
mLockFlags = aFlags;
|
||||
|
||||
// Obtain an ximage from the pixmap. ( I think this copy the bitmap )
|
||||
// FIX ME !!!! We need to copy the part locked into the mImage
|
||||
mView->LockLooper();
|
||||
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
// MOZ_TIMER_STOP(mLockTime);
|
||||
// MOZ_TIMER_LOG(("Time taken to lock: "));
|
||||
// MOZ_TIMER_PRINT(mLockTime);
|
||||
printf("Time taken to lock: %d\n", PR_Now() - mLockTime);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Unlock(void)
|
||||
{
|
||||
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
mUnlockTime = PR_Now();
|
||||
#endif
|
||||
|
||||
// g_print("nsDrawingSurfaceGTK::UnLock() called\n");
|
||||
if (!mLocked)
|
||||
{
|
||||
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If the lock was not read only, put the bits back on the pixmap
|
||||
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
|
||||
{
|
||||
// FIX ME!!!
|
||||
// Now draw the image ...
|
||||
}
|
||||
|
||||
// FIX ME!!!
|
||||
// Destroy mImage
|
||||
mView->UnlockLooper();
|
||||
|
||||
mLocked = PR_FALSE;
|
||||
|
||||
|
||||
#ifdef CHEAP_PERFORMANCE_MEASUREMENT
|
||||
printf("Time taken to unlock: %d\n", PR_Now() - mUnlockTime);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
*aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsOffscreen(PRBool *aOffScreen)
|
||||
{
|
||||
*aOffScreen = mIsOffscreen;//mBitmap ? PR_TRUE : PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: IsPixelAddressable(PRBool *aAddressable)
|
||||
{
|
||||
*aAddressable = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: GetPixelFormat(nsPixelFormat *aFormat)
|
||||
{
|
||||
*aFormat = mPixFormat;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView)
|
||||
{
|
||||
if(aView->LockLooper())
|
||||
{
|
||||
//remember dimensions
|
||||
mWidth=nscoord(aView->Bounds().Width()+1);
|
||||
mHeight=nscoord(aView->Bounds().Height()+1);
|
||||
|
||||
mView = aView;
|
||||
|
||||
aView->UnlockLooper();
|
||||
}
|
||||
|
||||
// XXX was i smoking crack when i wrote this comment?
|
||||
// this is definatly going to be on the screen, as it will be the window of a
|
||||
// widget or something.
|
||||
mIsOffscreen = PR_FALSE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: Init(BView *aView, PRUint32 aWidth,
|
||||
PRUint32 aHeight, PRUint32 aFlags)
|
||||
{
|
||||
NS_ASSERTION(!(aView == nsnull), "null BView");
|
||||
|
||||
//remember dimensions
|
||||
mWidth=aWidth;
|
||||
mHeight=aHeight;
|
||||
mFlags = aFlags;
|
||||
|
||||
// we can draw on this offscreen because it has no parent
|
||||
mIsOffscreen = PR_TRUE;
|
||||
|
||||
BRect r(0,0, mWidth-1, mHeight-1);
|
||||
mView = new BView(r, "", 0, 0);
|
||||
if (!mView)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
//if((aFlags & NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS) &&
|
||||
// (aWidth > 0) && (aHeight > 0))
|
||||
if(aWidth > 0 && aHeight > 0)
|
||||
{
|
||||
mBitmap = new BBitmap(r, B_RGBA32, true);
|
||||
if (!mBitmap)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (mBitmap->InitCheck()!=B_OK) {
|
||||
//for some reason, the bitmap isn't valid - delete the
|
||||
//bitmap object, then indicate failure
|
||||
delete mBitmap;
|
||||
mBitmap=NULL;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mBitmap->AddChild(mView);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireView(BView **aView)
|
||||
{
|
||||
*aView = mView;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: AcquireBitmap(BBitmap **aBitmap)
|
||||
{
|
||||
if(mBitmap && mBitmap->Lock())
|
||||
{
|
||||
mView->Sync();
|
||||
mBitmap->Unlock();
|
||||
}
|
||||
*aBitmap = mBitmap;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseView(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfaceBeOS :: ReleaseBitmap(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user