Move GrIPoint16 to SkIPoint16 (and remove GrPoint.h)
R=bsalomon@google.com, reed@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/309683002
This commit is contained in:
parent
78358bf624
commit
d537341e16
@ -25,7 +25,6 @@
|
|||||||
'<(skia_include_path)/gpu/GrKey.h',
|
'<(skia_include_path)/gpu/GrKey.h',
|
||||||
'<(skia_include_path)/gpu/GrPaint.h',
|
'<(skia_include_path)/gpu/GrPaint.h',
|
||||||
'<(skia_include_path)/gpu/GrPathRendererChain.h',
|
'<(skia_include_path)/gpu/GrPathRendererChain.h',
|
||||||
'<(skia_include_path)/gpu/GrPoint.h',
|
|
||||||
'<(skia_include_path)/gpu/GrRect.h',
|
'<(skia_include_path)/gpu/GrRect.h',
|
||||||
'<(skia_include_path)/gpu/GrRenderTarget.h',
|
'<(skia_include_path)/gpu/GrRenderTarget.h',
|
||||||
'<(skia_include_path)/gpu/GrSurface.h',
|
'<(skia_include_path)/gpu/GrSurface.h',
|
||||||
|
@ -59,7 +59,6 @@
|
|||||||
'gpu/GrRenderTarget.h',
|
'gpu/GrRenderTarget.h',
|
||||||
'gpu/GrSurface.h',
|
'gpu/GrSurface.h',
|
||||||
'gpu/GrTypesPriv.h',
|
'gpu/GrTypesPriv.h',
|
||||||
'gpu/GrPoint.h',
|
|
||||||
'config/sk_stdint.h',
|
'config/sk_stdint.h',
|
||||||
'config/SkUserConfig.h',
|
'config/SkUserConfig.h',
|
||||||
'pipe/SkGPipe.h',
|
'pipe/SkGPipe.h',
|
||||||
|
@ -11,6 +11,28 @@
|
|||||||
#include "SkMath.h"
|
#include "SkMath.h"
|
||||||
#include "SkScalar.h"
|
#include "SkScalar.h"
|
||||||
|
|
||||||
|
/** \struct SkIPoint16
|
||||||
|
|
||||||
|
SkIPoint holds two 16 bit integer coordinates
|
||||||
|
*/
|
||||||
|
struct SkIPoint16 {
|
||||||
|
int16_t fX, fY;
|
||||||
|
|
||||||
|
static SkIPoint16 Make(int x, int y) {
|
||||||
|
SkIPoint16 pt;
|
||||||
|
pt.set(x, y);
|
||||||
|
return pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t x() const { return fX; }
|
||||||
|
int16_t y() const { return fY; }
|
||||||
|
|
||||||
|
void set(int x, int y) {
|
||||||
|
fX = SkToS16(x);
|
||||||
|
fY = SkToS16(y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** \struct SkIPoint
|
/** \struct SkIPoint
|
||||||
|
|
||||||
SkIPoint holds two 32 bit integer coordinates
|
SkIPoint holds two 32 bit integer coordinates
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "GrColor.h"
|
#include "GrColor.h"
|
||||||
#include "GrPaint.h"
|
#include "GrPaint.h"
|
||||||
#include "GrPathRendererChain.h"
|
#include "GrPathRendererChain.h"
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "SkMatrix.h"
|
#include "SkMatrix.h"
|
||||||
|
@ -26,7 +26,7 @@ struct GrGlyph {
|
|||||||
SkPath* fPath;
|
SkPath* fPath;
|
||||||
PackedID fPackedID;
|
PackedID fPackedID;
|
||||||
GrIRect16 fBounds;
|
GrIRect16 fBounds;
|
||||||
GrIPoint16 fAtlasLocation;
|
SkIPoint16 fAtlasLocation;
|
||||||
|
|
||||||
void init(GrGlyph::PackedID packed, const SkIRect& bounds) {
|
void init(GrGlyph::PackedID packed, const SkIRect& bounds) {
|
||||||
fPlot = NULL;
|
fPlot = NULL;
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2010 Google Inc.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license that can be
|
|
||||||
* found in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GrPoint_DEFINED
|
|
||||||
#define GrPoint_DEFINED
|
|
||||||
|
|
||||||
#include "GrTypes.h"
|
|
||||||
#include "SkScalar.h"
|
|
||||||
#include "SkPoint.h"
|
|
||||||
|
|
||||||
struct GrIPoint16 {
|
|
||||||
int16_t fX, fY;
|
|
||||||
|
|
||||||
static GrIPoint16 Make(intptr_t x, intptr_t y) {
|
|
||||||
GrIPoint16 pt;
|
|
||||||
pt.set(x, y);
|
|
||||||
return pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t x() const { return fX; }
|
|
||||||
int16_t y() const { return fY; }
|
|
||||||
|
|
||||||
void set(intptr_t x, intptr_t y) {
|
|
||||||
fX = SkToS16(x);
|
|
||||||
fY = SkToS16(y);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -40,7 +40,7 @@ public:
|
|||||||
GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)),
|
GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)),
|
||||||
GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)));
|
GrNextPow2(random.nextRangeU(kMinRectSize, kMaxRectSize)));
|
||||||
*fRects[2].append() = SkISize::Make(128, 128);
|
*fRects[2].append() = SkISize::Make(128, 128);
|
||||||
*fRectLocations.append() = GrIPoint16::Make(0, 0);
|
*fRectLocations.append() = SkIPoint16::Make(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fCurRects = &fRects[0];
|
fCurRects = &fRects[0];
|
||||||
@ -142,7 +142,7 @@ private:
|
|||||||
int fCurRandRect;
|
int fCurRandRect;
|
||||||
SkTDArray<SkISize> fRects[3];
|
SkTDArray<SkISize> fRects[3];
|
||||||
SkTDArray<SkISize>* fCurRects;
|
SkTDArray<SkISize>* fCurRects;
|
||||||
SkTDArray<GrIPoint16> fRectLocations;
|
SkTDArray<SkIPoint16> fRectLocations;
|
||||||
GrRectanizer* fRectanizers[2];
|
GrRectanizer* fRectanizers[2];
|
||||||
GrRectanizer* fCurRectanizer;
|
GrRectanizer* fCurRectanizer;
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ void GrPlot::init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, si
|
|||||||
fBatchUploads = batchUploads;
|
fBatchUploads = batchUploads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void adjust_for_offset(GrIPoint16* loc, const GrIPoint16& offset) {
|
static inline void adjust_for_offset(SkIPoint16* loc, const SkIPoint16& offset) {
|
||||||
loc->fX += offset.fX;
|
loc->fX += offset.fX;
|
||||||
loc->fY += offset.fY;
|
loc->fY += offset.fY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrPlot::addSubImage(int width, int height, const void* image,
|
bool GrPlot::addSubImage(int width, int height, const void* image,
|
||||||
GrIPoint16* loc) {
|
SkIPoint16* loc) {
|
||||||
float percentFull = fRects->percentFull();
|
float percentFull = fRects->percentFull();
|
||||||
if (!fRects->addRect(width, height, loc)) {
|
if (!fRects->addRect(width, height, loc)) {
|
||||||
return false;
|
return false;
|
||||||
@ -203,7 +203,7 @@ void GrAtlasMgr::moveToHead(GrPlot* plot) {
|
|||||||
|
|
||||||
GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas,
|
||||||
int width, int height, const void* image,
|
int width, int height, const void* image,
|
||||||
GrIPoint16* loc) {
|
SkIPoint16* loc) {
|
||||||
// iterate through entire plot list for this atlas, see if we can find a hole
|
// iterate through entire plot list for this atlas, see if we can find a hole
|
||||||
// last one was most recently added and probably most empty
|
// last one was most recently added and probably most empty
|
||||||
for (int i = atlas->fPlots.count()-1; i >= 0; --i) {
|
for (int i = atlas->fPlots.count()-1; i >= 0; --i) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define GrAtlas_DEFINED
|
#define GrAtlas_DEFINED
|
||||||
|
|
||||||
|
|
||||||
#include "GrPoint.h"
|
#include "SkPoint.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "GrDrawTarget.h"
|
#include "GrDrawTarget.h"
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
|
|
||||||
GrTexture* texture() const { return fTexture; }
|
GrTexture* texture() const { return fTexture; }
|
||||||
|
|
||||||
bool addSubImage(int width, int height, const void*, GrIPoint16*);
|
bool addSubImage(int width, int height, const void*, SkIPoint16*);
|
||||||
|
|
||||||
GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
|
GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
|
||||||
void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
|
void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
|
||||||
@ -57,7 +57,7 @@ private:
|
|||||||
GrTexture* fTexture;
|
GrTexture* fTexture;
|
||||||
GrRectanizer* fRects;
|
GrRectanizer* fRects;
|
||||||
GrAtlasMgr* fAtlasMgr;
|
GrAtlasMgr* fAtlasMgr;
|
||||||
GrIPoint16 fOffset; // the offset of the plot in the backing texture
|
SkIPoint16 fOffset; // the offset of the plot in the backing texture
|
||||||
size_t fBytesPerPixel;
|
size_t fBytesPerPixel;
|
||||||
SkIRect fDirtyRect;
|
SkIRect fDirtyRect;
|
||||||
bool fDirty;
|
bool fDirty;
|
||||||
@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
// add subimage of width, height dimensions to atlas
|
// add subimage of width, height dimensions to atlas
|
||||||
// returns the containing GrPlot and location relative to the backing texture
|
// returns the containing GrPlot and location relative to the backing texture
|
||||||
GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16*);
|
GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, SkIPoint16*);
|
||||||
|
|
||||||
// remove reference to this plot
|
// remove reference to this plot
|
||||||
bool removePlot(GrAtlas* atlas, const GrPlot* plot);
|
bool removePlot(GrAtlas* atlas, const GrPlot* plot);
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include "GrColor.h"
|
#include "GrColor.h"
|
||||||
#include "GrEffectStage.h"
|
#include "GrEffectStage.h"
|
||||||
#include "GrPaint.h"
|
#include "GrPaint.h"
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrStencil.h"
|
#include "GrStencil.h"
|
||||||
#include "GrTemplates.h"
|
#include "GrTemplates.h"
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
#include "GrGpu.h"
|
#include "GrGpu.h"
|
||||||
#include "GrIndexBuffer.h"
|
#include "GrIndexBuffer.h"
|
||||||
#include "GrPath.h"
|
#include "GrPath.h"
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "GrRenderTarget.h"
|
#include "GrRenderTarget.h"
|
||||||
#include "GrTemplates.h"
|
#include "GrTemplates.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "GrPathUtils.h"
|
#include "GrPathUtils.h"
|
||||||
|
|
||||||
#include "GrPoint.h"
|
#include "GrTypes.h"
|
||||||
#include "SkGeometry.h"
|
#include "SkGeometry.h"
|
||||||
|
|
||||||
SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
|
SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#ifndef GrPathUtils_DEFINED
|
#ifndef GrPathUtils_DEFINED
|
||||||
#define GrPathUtils_DEFINED
|
#define GrPathUtils_DEFINED
|
||||||
|
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "SkRect.h"
|
#include "SkRect.h"
|
||||||
#include "SkPath.h"
|
#include "SkPath.h"
|
||||||
#include "SkTArray.h"
|
#include "SkTArray.h"
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#define GrPlotMgr_DEFINED
|
#define GrPlotMgr_DEFINED
|
||||||
|
|
||||||
#include "GrTypes.h"
|
#include "GrTypes.h"
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "SkTypes.h"
|
#include "SkTypes.h"
|
||||||
|
|
||||||
class GrPlotMgr : SkNoncopyable {
|
class GrPlotMgr : SkNoncopyable {
|
||||||
@ -35,7 +34,7 @@ public:
|
|||||||
sk_bzero(fBusy, fDim.fX * fDim.fY);
|
sk_bzero(fBusy, fDim.fX * fDim.fY);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool newPlot(GrIPoint16* loc) {
|
bool newPlot(SkIPoint16* loc) {
|
||||||
char* busy = fBusy;
|
char* busy = fBusy;
|
||||||
for (int y = 0; y < fDim.fY; y++) {
|
for (int y = 0; y < fDim.fY; y++) {
|
||||||
for (int x = 0; x < fDim.fX; x++) {
|
for (int x = 0; x < fDim.fX; x++) {
|
||||||
@ -68,7 +67,7 @@ private:
|
|||||||
};
|
};
|
||||||
char fStorage[STORAGE];
|
char fStorage[STORAGE];
|
||||||
char* fBusy;
|
char* fBusy;
|
||||||
GrIPoint16 fDim;
|
SkIPoint16 fDim;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
#ifndef GrRectanizer_DEFINED
|
#ifndef GrRectanizer_DEFINED
|
||||||
#define GrRectanizer_DEFINED
|
#define GrRectanizer_DEFINED
|
||||||
|
|
||||||
#include "GrPoint.h"
|
#include "GrTypes.h"
|
||||||
|
|
||||||
|
struct SkIPoint16;
|
||||||
|
|
||||||
class GrRectanizer {
|
class GrRectanizer {
|
||||||
public:
|
public:
|
||||||
@ -26,7 +28,7 @@ public:
|
|||||||
|
|
||||||
// Attempt to add a rect. Return true on success; false on failure. If
|
// Attempt to add a rect. Return true on success; false on failure. If
|
||||||
// successful the position in the atlas is returned in 'loc'.
|
// successful the position in the atlas is returned in 'loc'.
|
||||||
virtual bool addRect(int width, int height, GrIPoint16* loc) = 0;
|
virtual bool addRect(int width, int height, SkIPoint16* loc) = 0;
|
||||||
virtual float percentFull() const = 0;
|
virtual float percentFull() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "GrRectanizer_pow2.h"
|
#include "GrRectanizer_pow2.h"
|
||||||
|
|
||||||
bool GrRectanizerPow2::addRect(int width, int height, GrIPoint16* loc) {
|
bool GrRectanizerPow2::addRect(int width, int height, SkIPoint16* loc) {
|
||||||
if ((unsigned)width > (unsigned)this->width() ||
|
if ((unsigned)width > (unsigned)this->width() ||
|
||||||
(unsigned)height > (unsigned)this->height()) {
|
(unsigned)height > (unsigned)this->height()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define GrRectanizer_pow2_DEFINED
|
#define GrRectanizer_pow2_DEFINED
|
||||||
|
|
||||||
#include "GrRectanizer.h"
|
#include "GrRectanizer.h"
|
||||||
|
#include "SkPoint.h"
|
||||||
|
|
||||||
// This Rectanizer quantizes the incoming rects to powers of 2. Each power
|
// This Rectanizer quantizes the incoming rects to powers of 2. Each power
|
||||||
// of two can have, at most, one active row/shelf. Once a row/shelf for
|
// of two can have, at most, one active row/shelf. Once a row/shelf for
|
||||||
@ -29,7 +30,7 @@ public:
|
|||||||
sk_bzero(fRows, sizeof(fRows));
|
sk_bzero(fRows, sizeof(fRows));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool addRect(int w, int h, GrIPoint16* loc) SK_OVERRIDE;
|
virtual bool addRect(int w, int h, SkIPoint16* loc) SK_OVERRIDE;
|
||||||
|
|
||||||
virtual float percentFull() const SK_OVERRIDE {
|
virtual float percentFull() const SK_OVERRIDE {
|
||||||
return fAreaSoFar / ((float)this->width() * this->height());
|
return fAreaSoFar / ((float)this->width() * this->height());
|
||||||
@ -40,7 +41,7 @@ private:
|
|||||||
static const int kMaxExponent = 16;
|
static const int kMaxExponent = 16;
|
||||||
|
|
||||||
struct Row {
|
struct Row {
|
||||||
GrIPoint16 fLoc;
|
SkIPoint16 fLoc;
|
||||||
// fRowHeight is actually known by this struct's position in fRows
|
// fRowHeight is actually known by this struct's position in fRows
|
||||||
// but it is used to signal if there exists an open row of this height
|
// but it is used to signal if there exists an open row of this height
|
||||||
int fRowHeight;
|
int fRowHeight;
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GrRectanizer_skyline.h"
|
#include "GrRectanizer_skyline.h"
|
||||||
|
#include "SkPoint.h"
|
||||||
|
|
||||||
bool GrRectanizerSkyline::addRect(int width, int height, GrIPoint16* loc) {
|
bool GrRectanizerSkyline::addRect(int width, int height, SkIPoint16* loc) {
|
||||||
if ((unsigned)width > (unsigned)this->width() ||
|
if ((unsigned)width > (unsigned)this->width() ||
|
||||||
(unsigned)height > (unsigned)this->height()) {
|
(unsigned)height > (unsigned)this->height()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
seg->fWidth = this->width();
|
seg->fWidth = this->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool addRect(int w, int h, GrIPoint16* loc) SK_OVERRIDE;
|
virtual bool addRect(int w, int h, SkIPoint16* loc) SK_OVERRIDE;
|
||||||
|
|
||||||
virtual float percentFull() const SK_OVERRIDE{
|
virtual float percentFull() const SK_OVERRIDE{
|
||||||
return fAreaSoFar / ((float)this->width() * this->height());
|
return fAreaSoFar / ((float)this->width() * this->height());
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#ifndef GrTextContext_DEFINED
|
#ifndef GrTextContext_DEFINED
|
||||||
#define GrTextContext_DEFINED
|
#define GrTextContext_DEFINED
|
||||||
|
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "GrGlyph.h"
|
#include "GrGlyph.h"
|
||||||
#include "GrPaint.h"
|
#include "GrPaint.h"
|
||||||
#include "SkDeviceProperties.h"
|
#include "SkDeviceProperties.h"
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "GrAllocPool.h"
|
#include "GrAllocPool.h"
|
||||||
#include "GrFontScaler.h"
|
#include "GrFontScaler.h"
|
||||||
#include "GrTHashTable.h"
|
#include "GrTHashTable.h"
|
||||||
#include "GrPoint.h"
|
|
||||||
#include "GrGlyph.h"
|
#include "GrGlyph.h"
|
||||||
#include "GrDrawTarget.h"
|
#include "GrDrawTarget.h"
|
||||||
#include "GrAtlas.h"
|
#include "GrAtlas.h"
|
||||||
|
@ -22,7 +22,7 @@ static void test_rectanizer_basic(skiatest::Reporter* reporter, GrRectanizer* re
|
|||||||
REPORTER_ASSERT(reporter, kWidth == rectanizer->width());
|
REPORTER_ASSERT(reporter, kWidth == rectanizer->width());
|
||||||
REPORTER_ASSERT(reporter, kHeight == rectanizer->height());
|
REPORTER_ASSERT(reporter, kHeight == rectanizer->height());
|
||||||
|
|
||||||
GrIPoint16 loc;
|
SkIPoint16 loc;
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc));
|
REPORTER_ASSERT(reporter, rectanizer->addRect(50, 50, &loc));
|
||||||
REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f);
|
REPORTER_ASSERT(reporter, rectanizer->percentFull() > 0.0f);
|
||||||
@ -35,7 +35,7 @@ static void test_rectanizer_inserts(skiatest::Reporter*,
|
|||||||
const SkTDArray<SkISize>& rects) {
|
const SkTDArray<SkISize>& rects) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < rects.count(); ++i) {
|
for (i = 0; i < rects.count(); ++i) {
|
||||||
GrIPoint16 loc;
|
SkIPoint16 loc;
|
||||||
if (!rectanizer->addRect(rects[i].fWidth, rects[i].fHeight, &loc)) {
|
if (!rectanizer->addRect(rects[i].fWidth, rects[i].fHeight, &loc)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user