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

Side by Side Diff: bench/NinePatchBench.cpp

Issue 1992283002: Add drawBitmapLattice() API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add implementation for SkRecorder and SkPictureRecord Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | gm/ninepatchmultistretch.cpp » ('j') | include/core/SkCanvas.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Benchmark.h"
9 #include "SkCanvas.h"
10 #include "SkRect.h"
11 #include "SkString.h"
12
13 class NinePatchBench : public Benchmark {
14 public:
15 NinePatchBench(int* xDivs, int xCount, int* yDivs, int yCount, const SkISize & srcSize,
16 const SkRect& dst, const char* desc)
17 : fSrcSize(srcSize)
18 , fDst(dst)
19 {
20 fDivs.fXDivs = xDivs;
21 fDivs.fXCount = xCount;
22 fDivs.fYDivs = yDivs;
23 fDivs.fYCount = yCount;
24
25 fName = SkStringPrintf("NinePatch_%s", desc);
26 }
27
28 const char* onGetName() override {
29 return fName.c_str();
30 }
31
32 bool isSuitableFor(Backend backend) override {
33 return kRaster_Backend == backend || kGPU_Backend == backend;
34 }
35
36 void onDelayedSetup() override {
37 fBitmap.allocN32Pixels(fSrcSize.width(), fSrcSize.height());
38 fBitmap.eraseColor(0x880000FF);
39 }
40
41 void onDraw(int loops, SkCanvas* canvas) override {
42 for (int i = 0; i < loops; i++) {
43 canvas->drawBitmapNine(fBitmap, fDivs, fDst);
44 }
45 }
46
47 private:
48 SkISize fSrcSize;
49 SkCanvas::NinePatchDivs fDivs;
50 SkRect fDst;
51 SkString fName;
52 SkBitmap fBitmap;
53
54 typedef Benchmark INHERITED;
55 };
56
57 static int gDivs[2] = { 250, 750, };
58 DEF_BENCH(return new NinePatchBench(gDivs, 2, gDivs, 2, SkISize::Make(1000, 1000 ),
59 SkRect::MakeWH(4000.0f, 4000.0f), "StandardN ine");)
OLDNEW
« no previous file with comments | « no previous file | gm/ninepatchmultistretch.cpp » ('j') | include/core/SkCanvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698