Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: tools/PictureRenderer.cpp

Issue 513983002: Try out scalar picture sizes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update to ToT again Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/SerializationTest.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/PictureRenderer.cpp
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 72c72a5536bfb602681e74059927286deec0f869..ed5bdfe6125e697e5babbb545081f9ffe5dd25a0 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -191,7 +191,7 @@ void PictureRenderer::end() {
int PictureRenderer::getViewWidth() {
SkASSERT(fPicture != NULL);
- int width = SkScalarCeilToInt(fPicture->width() * fScaleFactor);
+ int width = SkScalarCeilToInt(fPicture->cullRect().width() * fScaleFactor);
if (fViewport.width() > 0) {
width = SkMin32(width, fViewport.width());
}
@@ -200,7 +200,7 @@ int PictureRenderer::getViewWidth() {
int PictureRenderer::getViewHeight() {
SkASSERT(fPicture != NULL);
- int height = SkScalarCeilToInt(fPicture->height() * fScaleFactor);
+ int height = SkScalarCeilToInt(fPicture->cullRect().height() * fScaleFactor);
if (fViewport.height() > 0) {
height = SkMin32(height, fViewport.height());
}
@@ -216,7 +216,8 @@ void PictureRenderer::buildBBoxHierarchy() {
if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(fPicture->width(), fPicture->height(),
+ SkCanvas* canvas = recorder.beginRecording(fPicture->cullRect().width(),
+ fPicture->cullRect().height(),
factory.get(),
this->recordFlags());
fPicture->draw(canvas);
@@ -355,7 +356,8 @@ static SkData* encode_bitmap_to_data(size_t*, const SkBitmap& bm) {
bool RecordPictureRenderer::render(SkBitmap** out) {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
SkPictureRecorder recorder;
- SkCanvas* canvas = recorder.beginRecording(this->getViewWidth(), this->getViewHeight(),
+ SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(this->getViewWidth()),
+ SkIntToScalar(this->getViewHeight()),
factory.get(),
this->recordFlags());
this->scaleToScaleFactor(canvas);
@@ -392,7 +394,8 @@ bool PipePictureRenderer::render(SkBitmap** out) {
fCanvas->flush();
if (NULL != out) {
*out = SkNEW(SkBitmap);
- setup_bitmap(*out, fPicture->width(), fPicture->height());
+ setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
+ SkScalarCeilToInt(fPicture->cullRect().height()));
fCanvas->readPixels(*out, 0, 0);
}
if (fEnableWrites) {
@@ -427,7 +430,8 @@ bool SimplePictureRenderer::render(SkBitmap** out) {
fCanvas->flush();
if (NULL != out) {
*out = SkNEW(SkBitmap);
- setup_bitmap(*out, fPicture->width(), fPicture->height());
+ setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
+ SkScalarCeilToInt(fPicture->cullRect().height()));
fCanvas->readPixels(*out, 0, 0);
}
if (fEnableWrites) {
@@ -479,10 +483,10 @@ void TiledPictureRenderer::init(const SkPicture* pict, const SkString* writePath
this->buildBBoxHierarchy();
if (fTileWidthPercentage > 0) {
- fTileWidth = sk_float_ceil2int(float(fTileWidthPercentage * fPicture->width() / 100));
+ fTileWidth = SkScalarCeilToInt(float(fTileWidthPercentage * fPicture->cullRect().width() / 100));
}
if (fTileHeightPercentage > 0) {
- fTileHeight = sk_float_ceil2int(float(fTileHeightPercentage * fPicture->height() / 100));
+ fTileHeight = SkScalarCeilToInt(float(fTileHeightPercentage * fPicture->cullRect().height() / 100));
}
if (fTileMinPowerOf2Width > 0) {
@@ -647,7 +651,8 @@ bool TiledPictureRenderer::render(SkBitmap** out) {
SkBitmap bitmap;
if (out){
*out = SkNEW(SkBitmap);
- setup_bitmap(*out, fPicture->width(), fPicture->height());
+ setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()),
+ SkScalarCeilToInt(fPicture->cullRect().height()));
setup_bitmap(&bitmap, fTileWidth, fTileHeight);
}
bool success = true;
@@ -712,7 +717,8 @@ SkString TiledPictureRenderer::getConfigNameInternal() {
void PlaybackCreationRenderer::setup() {
SkAutoTDelete<SkBBHFactory> factory(this->getFactory());
fRecorder.reset(SkNEW(SkPictureRecorder));
- SkCanvas* canvas = fRecorder->beginRecording(this->getViewWidth(), this->getViewHeight(),
+ SkCanvas* canvas = fRecorder->beginRecording(SkIntToScalar(this->getViewWidth()),
+ SkIntToScalar(this->getViewHeight()),
factory.get(),
this->recordFlags());
this->scaleToScaleFactor(canvas);
@@ -754,8 +760,8 @@ public:
#endif
virtual bool render(SkBitmap** out = NULL) SK_OVERRIDE {
- SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()),
- SkIntToScalar(fPicture->height()));
+ SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->cullRect().width()),
+ SkIntToScalar(fPicture->cullRect().height()));
SkData* data = SkPictureUtils::GatherPixelRefs(fPicture, bounds);
SkSafeUnref(data);
« no previous file with comments | « tests/SerializationTest.cpp ('k') | tools/bench_pictures_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698