| Index: samplecode/SampleTextureDomain.cpp
|
| diff --git a/samplecode/SampleTextureDomain.cpp b/samplecode/SampleTextureDomain.cpp
|
| index 16e7a16cddfa9a9862e0e18c21b99038642ed4c3..854df6ecfd9f0ea904937104bd8ff2075b8e2074 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;
|
|
|