fold sk_pixel_iter.h into ToolUtils

The single class in it is already in the ToolUtils namespace.

Change-Id: Iefa69690c4aa9b218784eb5edcfe7dba8721747b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/202314
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2019-03-20 11:43:12 -05:00
parent ea3f014e2b
commit 0498857cee
6 changed files with 46 additions and 63 deletions

View File

@ -473,7 +473,6 @@ DM_SRCS_ALL = struct(
"tools/gpu/**/*.h",
"tools/random_parse_path.cpp",
"tools/random_parse_path.h",
"tools/sk_pixel_iter.h",
"tools/ToolUtils.cpp",
"tools/ToolUtils.h",
"tools/timer/*.cpp",

View File

@ -38,7 +38,7 @@
#include "SkSurface.h"
#include "SkTypes.h"
#include "Test.h"
#include "sk_pixel_iter.h"
#include "ToolUtils.h"
#include "GrContextFactory.h"

View File

@ -30,7 +30,6 @@
#include "Resources.h"
#include "ToolUtils.h"
#include "sk_pixel_iter.h"
#include "GrContextPriv.h"
#include "GrContextThreadSafeProxy.h"

View File

@ -8,8 +8,8 @@
#include "SkCanvas.h"
#include "SkSurface.h"
#include "SkVertices.h"
#include "sk_pixel_iter.h"
#include "Test.h"
#include "ToolUtils.h"
static bool equal(const SkVertices* v0, const SkVertices* v1) {
if (v0->mode() != v1->mode()) {

View File

@ -16,11 +16,13 @@
#include "SkFontTypes.h"
#include "SkImageEncoder.h"
#include "SkImageInfo.h"
#include "SkPixmap.h"
#include "SkRandom.h"
#include "SkRect.h"
#include "SkRefCnt.h"
#include "SkScalar.h"
#include "SkStream.h"
#include "SkSurface.h"
#include "SkTArray.h"
#include "SkTDArray.h"
#include "SkTypeface.h"
@ -229,6 +231,48 @@ inline bool EncodeImageToFile(const char* path, const T& src, SkEncodedImageForm
bool copy_to(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src);
void copy_to_g8(SkBitmap* dst, const SkBitmap& src);
class PixelIter {
public:
PixelIter();
PixelIter(SkSurface* surf) {
SkPixmap pm;
if (!surf->peekPixels(&pm)) {
pm.reset();
}
this->reset(pm);
}
void reset(const SkPixmap& pm) {
fPM = pm;
fLoc = {-1, 0};
}
void* next(SkIPoint* loc = nullptr) {
if (!fPM.addr()) {
return nullptr;
}
fLoc.fX += 1;
if (fLoc.fX >= fPM.width()) {
fLoc.fX = 0;
if (++fLoc.fY >= fPM.height()) {
this->setDone();
return nullptr;
}
}
if (loc) {
*loc = fLoc;
}
return fPM.writable_addr(fLoc.fX, fLoc.fY);
}
void setDone() { fPM.reset(); }
private:
SkPixmap fPM;
SkIPoint fLoc;
};
} // namespace ToolUtils
#endif // ToolUtils_DEFINED

View File

@ -1,59 +0,0 @@
/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef sk_pixel_iter_DEFINED
#define sk_pixel_iter_DEFINED
#include "SkPixmap.h"
#include "SkSurface.h"
namespace ToolUtils {
class PixelIter {
public:
PixelIter();
PixelIter(SkSurface* surf) {
SkPixmap pm;
if (!surf->peekPixels(&pm)) {
pm.reset();
}
this->reset(pm);
}
void reset(const SkPixmap& pm) {
fPM = pm;
fLoc = {-1, 0};
}
void* next(SkIPoint* loc = nullptr) {
if (!fPM.addr()) {
return nullptr;
}
fLoc.fX += 1;
if (fLoc.fX >= fPM.width()) {
fLoc.fX = 0;
if (++fLoc.fY >= fPM.height()) {
this->setDone();
return nullptr;
}
}
if (loc) {
*loc = fLoc;
}
return fPM.writable_addr(fLoc.fX, fLoc.fY);
}
void setDone() { fPM.reset(); }
private:
SkPixmap fPM;
SkIPoint fLoc;
};
} // namespace ToolUtils
#endif // ToolUtils_DEFINED