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

Side by Side Diff: gm/bitmapsource.cpp

Issue 1363913002: Remove SkBitmapSource (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: immutable bitmap Created 5 years, 2 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 | « gm/bigtileimagefilter.cpp ('k') | gm/colorcube.cpp » ('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 * Copyright 2013 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 "gm.h"
9
10 #include "SkBitmapSource.h"
11
12 // This GM exercises the SkBitmapSource ImageFilter class.
13
14 class BitmapSourceGM : public skiagm::GM {
15 public:
16 BitmapSourceGM() {
17 }
18
19 protected:
20 SkString onShortName() override {
21 return SkString("bitmapsource");
22 }
23
24 SkISize onISize() override { return SkISize::Make(500, 150); }
25
26 void onOnceBeforeDraw() override {
27 fBitmap = sk_tool_utils::create_string_bitmap(100, 100, 0xFFFFFFFF, 20, 70, 96, "e");
28 }
29
30 static void FillRectFiltered(SkCanvas* canvas, const SkRect& clipRect, SkIma geFilter* filter) {
31 SkPaint paint;
32 paint.setImageFilter(filter);
33 canvas->save();
34 canvas->clipRect(clipRect);
35 canvas->drawPaint(paint);
36 canvas->restore();
37 }
38
39 void onDraw(SkCanvas* canvas) override {
40 canvas->clear(SK_ColorBLACK);
41 {
42 SkRect srcRect = SkRect::MakeXYWH(20, 20, 30, 30);
43 SkRect dstRect = SkRect::MakeXYWH(0, 10, 60, 60);
44 SkRect clipRect = SkRect::MakeXYWH(0, 0, 100, 100);
45 SkRect bounds;
46 fBitmap.getBounds(&bounds);
47 SkAutoTUnref<SkImageFilter> bitmapSource(SkBitmapSource::Create(fBit map));
48 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRect(SkBitmapSource::Crea te(fBitmap, srcRect, srcRect));
49 SkAutoTUnref<SkImageFilter> bitmapSourceSrcRectDstRect(SkBitmapSourc e::Create(fBitmap, srcRect, dstRect));
50 SkAutoTUnref<SkImageFilter> bitmapSourceDstRectOnly(SkBitmapSource:: Create(fBitmap, bounds, dstRect));
51
52 // Draw an unscaled bitmap.
53 FillRectFiltered(canvas, clipRect, bitmapSource);
54 canvas->translate(SkIntToScalar(100), 0);
55
56 // Draw an unscaled subset of the source bitmap (srcRect -> srcRect) .
57 FillRectFiltered(canvas, clipRect, bitmapSourceSrcRect);
58 canvas->translate(SkIntToScalar(100), 0);
59
60 // Draw a subset of the bitmap scaled to a destination rect (srcRect -> dstRect).
61 FillRectFiltered(canvas, clipRect, bitmapSourceSrcRectDstRect);
62 canvas->translate(SkIntToScalar(100), 0);
63
64 // Draw the entire bitmap scaled to a destination rect (bounds -> ds tRect).
65 FillRectFiltered(canvas, clipRect, bitmapSourceDstRectOnly);
66 canvas->translate(SkIntToScalar(100), 0);
67 }
68 }
69
70 private:
71 SkBitmap fBitmap;
72 typedef GM INHERITED;
73 };
74
75 ///////////////////////////////////////////////////////////////////////////////
76
77 DEF_GM( return new BitmapSourceGM; )
OLDNEW
« no previous file with comments | « gm/bigtileimagefilter.cpp ('k') | gm/colorcube.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698