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

Unified Diff: gm/image.cpp

Issue 19729007: Add SkImage->draw() call with src and dst rects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | « no previous file | include/core/SkImage.h » ('j') | include/core/SkImage.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image.cpp
diff --git a/gm/image.cpp b/gm/image.cpp
index 71fe0e176f094bdab2f047f93f79f2eb640cb6c0..df50e0be18fa9d5feb0a59ec3d29a66e2c4e36ee 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -91,6 +91,22 @@ static void test_surface(SkCanvas* canvas, SkSurface* surf) {
imgG->draw(canvas, 0, 80, &paint);
surf->draw(canvas, 0, 160, &paint);
+ SkRect src1, src2, src3;
+ src1.set(0, 0, surf->width(), surf->height());
+ src2.set(-surf->width() / 2, -surf->height() / 2, surf->width(), surf->height());
+ src3.set(0, 0, surf->width() / 2, surf->height() / 2);
+
+ SkRect dst1, dst2, dst3, dst4;
+ dst1.set(0, 240, 65, 305);
+ dst2.set(0, 320, 65, 385);
+ dst3.set(0, 400, 65, 465);
+ dst4.set(0, 480, 65, 545);
+
+ imgR->draw(canvas, &src1, dst1, &paint);
+ imgG->draw(canvas, &src2, dst2, &paint);
+ imgR->draw(canvas, &src3, dst3, &paint);
+ imgG->draw(canvas, NULL, dst4, &paint);
+
imgG->unref();
imgR->unref();
}
@@ -122,7 +138,7 @@ protected:
}
virtual SkISize onISize() {
- return SkISize::Make(800, 500);
+ return SkISize::Make(800, 1200);
}
virtual void onDraw(SkCanvas* canvas) {
@@ -133,22 +149,30 @@ protected:
static const char* kLabel1 = "Original Img";
static const char* kLabel2 = "Modified Img";
static const char* kLabel3 = "Cur Surface";
+ static const char* kLabel4 = "Full Crop";
+ static const char* kLabel5 = "Over-crop";
+ static const char* kLabel6 = "Upper-left";
+ static const char* kLabel7 = "No Crop";
- static const char* kLabel4 = "Pre-Alloc Img";
- static const char* kLabel5 = "New Alloc Img";
- static const char* kLabel6 = "SkPicture";
- static const char* kLabel7 = "GPU";
+ static const char* kLabel8 = "Pre-Alloc Img";
+ static const char* kLabel9 = "New Alloc Img";
+ static const char* kLabel10 = "SkPicture";
+ static const char* kLabel11 = "GPU";
SkPaint textPaint;
canvas->drawText(kLabel1, strlen(kLabel1), 10, 60, textPaint);
canvas->drawText(kLabel2, strlen(kLabel2), 10, 140, textPaint);
canvas->drawText(kLabel3, strlen(kLabel3), 10, 220, textPaint);
-
- canvas->drawText(kLabel4, strlen(kLabel4), 80, 10, textPaint);
- canvas->drawText(kLabel5, strlen(kLabel5), 160, 10, textPaint);
- canvas->drawText(kLabel6, strlen(kLabel6), 250, 10, textPaint);
- canvas->drawText(kLabel7, strlen(kLabel7), 340, 10, textPaint);
+ canvas->drawText(kLabel4, strlen(kLabel4), 10, 300, textPaint);
+ canvas->drawText(kLabel5, strlen(kLabel5), 10, 380, textPaint);
+ canvas->drawText(kLabel6, strlen(kLabel6), 10, 460, textPaint);
+ canvas->drawText(kLabel7, strlen(kLabel7), 10, 540, textPaint);
+
+ canvas->drawText(kLabel8, strlen(kLabel8), 80, 10, textPaint);
+ canvas->drawText(kLabel9, strlen(kLabel9), 160, 10, textPaint);
+ canvas->drawText(kLabel10, strlen(kLabel10), 250, 10, textPaint);
+ canvas->drawText(kLabel11, strlen(kLabel11), 340, 10, textPaint);
canvas->translate(80, 20);
« no previous file with comments | « no previous file | include/core/SkImage.h » ('j') | include/core/SkImage.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698