180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc. 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "gm.h" 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkCanvas.h" 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkGradientShader.h" 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkGraphics.h" 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkPath.h" 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRegion.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkShader.h" 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void make_bitmap(SkBitmap* bitmap) { 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->setConfig(SkBitmap::kARGB_8888_Config, 64, 64); 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->allocPixels(); 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkCanvas canvas(*bitmap); 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas.drawColor(SK_ColorRED); 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPaint paint; 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru paint.setAntiAlias(true); 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkPoint pts[] = { { 0, 0 }, { 64, 64 } }; 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkColor colors[] = { SK_ColorWHITE, SK_ColorBLUE }; 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru paint.setShader(SkGradientShader::CreateLinear(pts, colors, NULL, 2, 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkShader::kClamp_TileMode))->unref(); 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas.drawCircle(32, 32, 32, paint); 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass DrawBitmapRect2 : public skiagm::GM { 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool fUseIRect; 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru DrawBitmapRect2(bool useIRect) : fUseIRect(useIRect) { 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkString onShortName() SK_OVERRIDE { 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString str; 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru str.printf("bitmaprect_%s", fUseIRect ? "i" : "s"); 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return str; 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkISize onISize() SK_OVERRIDE { 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return SkISize::Make(640, 480); 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawColor(0xFFCCCCCC); 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru const SkIRect src[] = { 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru { 0, 0, 32, 32 }, 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru { 0, 0, 80, 80 }, 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru { 32, 32, 96, 96 }, 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru { -32, -32, 32, 32, } 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPaint paint; 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru paint.setStyle(SkPaint::kStroke_Style); 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBitmap bitmap; 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru make_bitmap(&bitmap); 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect dstR = { 0, 200, 128, 380 }; 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->translate(16, 40); 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru for (size_t i = 0; i < SK_ARRAY_COUNT(src); i++) { 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect srcR; 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru srcR.set(src[i]); 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmap(bitmap, 0, 0, &paint); 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (!fUseIRect) { 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, &paint); 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } else { 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint); 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawRect(dstR, paint); 8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawRect(srcR, paint); 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->translate(160, 0); 8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef skiagm::GM INHERITED; 8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////////////// 9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void make_3x3_bitmap(SkBitmap* bitmap) { 9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static const int gXSize = 3; 9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static const int gYSize = 3; 9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkColor textureData[gXSize][gYSize] = { 97363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger { SK_ColorRED, SK_ColorWHITE, SK_ColorBLUE }, 98363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger { SK_ColorGREEN, SK_ColorBLACK, SK_ColorCYAN }, 99363e546ed626b6dbbc42f5db87b3594bc0b5944bDerek Sollenberger { SK_ColorYELLOW, SK_ColorGRAY, SK_ColorMAGENTA } 10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru }; 10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->setConfig(SkBitmap::kARGB_8888_Config, gXSize, gYSize); 10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->allocPixels(); 10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkAutoLockPixels lock(*bitmap); 10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru for (int y = 0; y < gYSize; y++) { 10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru for (int x = 0; x < gXSize; x++) { 10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *bitmap->getAddr32(x, y) = textureData[x][y]; 11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// This GM attempts to make visible any issues drawBitmapRectToRect may have 11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// with partial source rects. In this case the eight pixels on the border 11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// should be half the width/height of the central pixel, i.e.: 11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// __|____|__ 11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// | | 11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// __|____|__ 12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// | | 12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass DrawBitmapRect3 : public skiagm::GM { 12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru DrawBitmapRect3() { 12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru this->setBGColor(SK_ColorBLACK); 12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkString onShortName() SK_OVERRIDE { 12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString str; 13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru str.printf("3x3bitmaprect"); 13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return str; 13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkISize onISize() SK_OVERRIDE { 13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return SkISize::Make(640, 480); 13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBitmap bitmap; 14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru make_3x3_bitmap(&bitmap); 14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect srcR = { 0.5f, 0.5f, 2.5f, 2.5f }; 14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect dstR = { 100, 100, 300, 200 }; 14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRectToRect(bitmap, &srcR, dstR, NULL); 14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef skiagm::GM INHERITED; 15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////////////// 15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic void make_big_bitmap(SkBitmap* bitmap) { 15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static const int gXSize = 4096; 15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static const int gYSize = 4096; 15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru static const int gBorderWidth = 10; 15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->setConfig(SkBitmap::kARGB_8888_Config, gXSize, gYSize); 16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bitmap->allocPixels(); 16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkAutoLockPixels lock(*bitmap); 16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru for (int y = 0; y < gYSize; ++y) { 16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru for (int x = 0; x < gXSize; ++x) { 16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (x <= gBorderWidth || x >= gXSize-gBorderWidth || 16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru y <= gBorderWidth || y >= gYSize-gBorderWidth) { 16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *bitmap->getAddr32(x, y) = 0x88FFFFFF; 16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } else { 17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *bitmap->getAddr32(x, y) = 0x88FF0000; 17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// This GM attempts to reveal any issues we may have when the GPU has to 17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// break up a large texture in order to draw it. The XOR transfer mode will 17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// create stripes in the image if there is imprecision in the destination 17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// tile placement. 18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass DrawBitmapRect4 : public skiagm::GM { 18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru bool fUseIRect; 18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic: 18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru DrawBitmapRect4(bool useIRect) : fUseIRect(useIRect) { 18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru this->setBGColor(0x88444444); 18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected: 18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkString onShortName() SK_OVERRIDE { 18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkString str; 19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru str.printf("bigbitmaprect_%s", fUseIRect ? "i" : "s"); 19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return str; 19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual SkISize onISize() SK_OVERRIDE { 19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return SkISize::Make(640, 480); 19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkXfermode* mode = SkXfermode::Create(SkXfermode::kXor_Mode); 20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkPaint paint; 20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru paint.setAlpha(128); 20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru paint.setXfermode(mode)->unref(); 20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkBitmap bitmap; 20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru make_big_bitmap(&bitmap); 20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect srcR1 = { 0.0f, 0.0f, 4096.0f, 2040.0f }; 21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect dstR1 = { 10.1f, 10.1f, 629.9f, 400.9f }; 21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect srcR2 = { 4085.0f, 10.0f, 4087.0f, 12.0f }; 21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkRect dstR2 = { 10, 410, 30, 430 }; 21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (!fUseIRect) { 21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRectToRect(bitmap, &srcR1, dstR1, &paint); 21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRectToRect(bitmap, &srcR2, dstR2, &paint); 21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } else { 21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkIRect iSrcR1, iSrcR2; 22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru srcR1.roundOut(&iSrcR1); 22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru srcR2.roundOut(&iSrcR2); 22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRect(bitmap, &iSrcR1, dstR1, &paint); 22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru canvas->drawBitmapRect(bitmap, &iSrcR2, dstR2, &paint); 22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate: 23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru typedef skiagm::GM INHERITED; 23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru////////////////////////////////////////////////////////////////////////////// 23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GM* MyFactory0(void*) { return new DrawBitmapRect2(false); } 23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GM* MyFactory1(void*) { return new DrawBitmapRect2(true); } 23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GM* MyFactory2(void*) { return new DrawBitmapRect3(); } 23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_BUILD_FOR_ANDROID 24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GM* MyFactory3(void*) { return new DrawBitmapRect4(false); } 24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GM* MyFactory4(void*) { return new DrawBitmapRect4(true); } 24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GMRegistry reg0(MyFactory0); 24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GMRegistry reg1(MyFactory1); 24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GMRegistry reg2(MyFactory2); 24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SK_BUILD_FOR_ANDROID 25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GMRegistry reg3(MyFactory3); 25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustatic skiagm::GMRegistry reg4(MyFactory4); 25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 254