diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-05 15:32:21 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-05 15:32:21 +0000 |
commit | 76f10a3bd936af7dbe2b5873d5a7eedd73cdc5da (patch) | |
tree | 7fb5b2990d2cd9e07c98708389308fe9d0ebc584 /samplecode | |
parent | cb6adecd4d37ae23c89a473a5f648584e0428520 (diff) |
remove SkCanvas::createCompatibleDevice, and add SkCanvas::newSurface
BUG=skia:
R=bsalomon@google.com
Review URL: https://codereview.chromium.org/154163002
git-svn-id: http://skia.googlecode.com/svn/trunk@13319 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleTextureDomain.cpp | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp index 16e7a16cdd..854df6ecfd 100644 --- a/samplecode/SampleTextureDomain.cpp +++ b/samplecode/SampleTextureDomain.cpp @@ -9,7 +9,7 @@ #include "SkBlurMask.h" #include "SkBlurMaskFilter.h" #include "SkCanvas.h" -#include "SkDevice.h" +#include "SkSurface.h" static SkBitmap make_bitmap() { SkBitmap bm; @@ -45,7 +45,7 @@ protected: } virtual void onDrawContent(SkCanvas* canvas) { - SkIRect srcRect; + SkRect srcRect; SkRect dstRect; SkPaint paint; paint.setFilterLevel(SkPaint::kLow_FilterLevel); @@ -53,54 +53,53 @@ protected: // Test that bitmap draws from malloc-backed bitmaps respect // the constrained texture domain. srcRect.setXYWH(1, 1, 3, 3); - dstRect.setXYWH(5.0f, 5.0f, 305.0f, 305.0f); - canvas->drawBitmapRect(fBM, &srcRect, dstRect, &paint); + dstRect.setXYWH(5, 5, 305, 305); + canvas->drawBitmapRectToRect(fBM, &srcRect, dstRect, &paint); // Test that bitmap draws across separate devices also respect // the constrainted texture domain. // Note: GPU-backed bitmaps follow a different rendering path // when copying from one GPU device to another. - SkAutoTUnref<SkBaseDevice> secondDevice(canvas->createCompatibleDevice( - SkBitmap::kARGB_8888_Config, 5, 5, true)); - SkCanvas secondCanvas(secondDevice.get()); + SkImageInfo info = SkImageInfo::MakeN32(5, 5, kOpaque_SkAlphaType); + SkAutoTUnref<SkSurface> surface(canvas->newSurface(info)); srcRect.setXYWH(1, 1, 3, 3); - dstRect.setXYWH(1.0f, 1.0f, 3.0f, 3.0f); - secondCanvas.drawBitmapRect(fBM, &srcRect, dstRect, &paint); + dstRect.setXYWH(1, 1, 3, 3); + surface->getCanvas()->drawBitmapRectToRect(fBM, &srcRect, dstRect, + &paint); - SkBitmap deviceBitmap = secondDevice->accessBitmap(false); + SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); srcRect.setXYWH(1, 1, 3, 3); - dstRect.setXYWH(405.0f, 5.0f, 305.0f, 305.0f); - canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint); + dstRect.setXYWH(405, 5, 305, 305); + image->draw(canvas, &srcRect, dstRect, &paint); // Test that bitmap blurring using a subrect // renders correctly srcRect.setXYWH(1, 1, 3, 3); - dstRect.setXYWH(5.0f, 405.0f, 305.0f, 305.0f); + dstRect.setXYWH(5, 405, 305, 305); SkMaskFilter* mf = SkBlurMaskFilter::Create( SkBlurMaskFilter::kNormal_BlurStyle, SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), SkBlurMaskFilter::kHighQuality_BlurFlag | SkBlurMaskFilter::kIgnoreTransform_BlurFlag); paint.setMaskFilter(mf)->unref(); - canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint); + image->draw(canvas, &srcRect, dstRect, &paint); // Blur and a rotation + NULL src rect // This should not trigger the texture domain code // but it will test a code path in SkGpuDevice::drawBitmap // that handles blurs with rects transformed to non- // orthogonal rects. It also tests the NULL src rect handling - mf = SkBlurMaskFilter::Create( - SkBlurMaskFilter::kNormal_BlurStyle, - SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)), - SkBlurMaskFilter::kHighQuality_BlurFlag); + mf = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle, + SkBlurMask::ConvertRadiusToSigma(5), + SkBlurMaskFilter::kHighQuality_BlurFlag); paint.setMaskFilter(mf)->unref(); - dstRect.setXYWH(-150.0f, -150.0f, 300.0f, 300.0f); + dstRect.setXYWH(-150, -150, 300, 300); canvas->translate(550, 550); canvas->rotate(45); - canvas->drawBitmapRect(fBM, NULL, dstRect, &paint); + canvas->drawBitmapRectToRect(fBM, NULL, dstRect, &paint); } private: typedef SkView INHERITED; |