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

Side by Side Diff: gm/tiledscaledbitmap.cpp

Issue 675823002: Fix the way we patch up the matrix for scaled images that aren't (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: don't tile the new GM Created 6 years, 1 month 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 | gyp/gmslides.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 /*
3 * Copyright 2014 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8 #include "gm.h"
9
10 #include "Resources.h"
tfarina 2014/10/30 15:30:16 looks like it is unused after make_bm().
11 #include "SkBitmap.h"
12 #include "SkImageDecoder.h"
13 #include "SkPaint.h"
14 #include "SkShader.h"
15 #include "SkStream.h"
16
17
18 /***
19 *
20 * This GM reproduces Skia bug 2904, in which a tiled bitmap shader was failing to draw correctly
21 * when fractional image scaling was ignored by the high quality bitmap scaler.
22 *
23 ***/
24
25 namespace skiagm {
26
27 class TiledScaledBitmapGM : public GM {
28 public:
29
30 TiledScaledBitmapGM() {
31 }
32
33 protected:
34 virtual SkString onShortName() {
tfarina 2014/10/30 15:30:16 SK_OVERRIDE?
35 return SkString("tiledscaledbitmap");
36 }
37
38 virtual SkISize onISize() {
tfarina 2014/10/30 15:30:16 SK_OVERRIDE?
39 return SkISize::Make(1016, 616);
40 }
41
42 virtual uint32_t onGetFlags() const SK_OVERRIDE {
43 return kSkipTiled_Flag;
44 }
45
46 static SkBitmap make_bm(int width, int height) {
47 SkBitmap bm;
48 bm.allocN32Pixels(width, height);
49 bm.eraseColor(SK_ColorTRANSPARENT);
50 SkCanvas canvas(bm);
51 SkPaint paint;
52 paint.setAntiAlias(true);
53 canvas.drawCircle(width/2.f, height/2.f, width/4.f, paint);
54 return bm;
55 }
56
57 virtual void onOnceBeforeDraw() SK_OVERRIDE {
58 fBitmap = make_bm(360, 288);
59 }
60
61 virtual void onDraw(SkCanvas* canvas) {
tfarina 2014/10/30 15:30:16 SK_OVERRIDE?
62 SkPaint paint;
63
64 paint.setAntiAlias(true);
65 paint.setFilterLevel(SkPaint::kHigh_FilterLevel);
66
67 SkMatrix mat;
68 mat.setScale(121.f/360.f, 93.f/288.f);
69 mat.postTranslate(-72, -72);
70
71 SkShader *shader = SkShader::CreateBitmapShader(fBitmap, SkShader::kRepe at_TileMode, SkShader::kRepeat_TileMode, &mat);
72 paint.setShader(shader);
73
74 SkSafeUnref(shader);
75 canvas->drawRectCoords(8,8,1008, 608, paint);
76 }
77
78 private:
79 SkBitmap fBitmap;
80
81 typedef GM INHERITED;
82 };
83
84 //////////////////////////////////////////////////////////////////////////////
85
86 DEF_GM(return SkNEW(TiledScaledBitmapGM);)
87
88 }
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698