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

Side by Side Diff: tests/FlatDataTest.cpp

Issue 295793002: stop calling SkBitmap::flatten (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
11 #include "SkColorFilter.h" 11 #include "SkColorFilter.h"
12 #include "SkGradientShader.h" 12 #include "SkGradientShader.h"
13 #include "SkPaint.h" 13 #include "SkPaint.h"
14 #include "SkPictureFlat.h" 14 #include "SkPictureFlat.h"
15 #include "SkShader.h" 15 #include "SkShader.h"
16 #include "SkXfermode.h" 16 #include "SkXfermode.h"
17 #include "Test.h" 17 #include "Test.h"
18 18
19 struct SkFlattenableTraits { 19 struct SkFlattenableTraits {
20 static void Flatten(SkWriteBuffer& buffer, const SkFlattenable& flattenable) { 20 static void Flatten(SkWriteBuffer& buffer, const SkFlattenable& flattenable) {
21 buffer.writeFlattenable(&flattenable); 21 buffer.writeFlattenable(&flattenable);
22 } 22 }
23 }; 23 };
24 struct SkBitmapTraits {
25 static void Flatten(SkWriteBuffer& buffer, const SkBitmap& bitmap) {
26 bitmap.flatten(buffer);
27 }
28 };
29 24
30 class Controller : public SkChunkFlatController { 25 class Controller : public SkChunkFlatController {
31 public: 26 public:
32 Controller() : INHERITED(1024) { 27 Controller() : INHERITED(1024) {
33 this->INHERITED::setNamedFactorySet(SkNEW(SkNamedFactorySet))->unref(); 28 this->INHERITED::setNamedFactorySet(SkNEW(SkNamedFactorySet))->unref();
34 } 29 }
35 private: 30 private:
36 typedef SkChunkFlatController INHERITED; 31 typedef SkChunkFlatController INHERITED;
37 }; 32 };
38 33
(...skipping 19 matching lines...) Expand all
58 points[0].set(0, 0); 53 points[0].set(0, 0);
59 points[1].set(SkIntToScalar(20), SkIntToScalar(20)); 54 points[1].set(SkIntToScalar(20), SkIntToScalar(20));
60 SkColor colors[2]; 55 SkColor colors[2];
61 colors[0] = SK_ColorRED; 56 colors[0] = SK_ColorRED;
62 colors[1] = SK_ColorBLUE; 57 colors[1] = SK_ColorBLUE;
63 58
64 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, colors, NULL, 2, 59 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateLinear(points, colors, NULL, 2,
65 SkShader::kRepe at_TileMode)); 60 SkShader::kRepe at_TileMode));
66 testCreate<SkFlattenableTraits>(reporter, *shader); 61 testCreate<SkFlattenableTraits>(reporter, *shader);
67 62
68 // Test SkBitmap
69 {
70 SkBitmap bm;
71 bm.allocN32Pixels(50, 50);
72 SkCanvas canvas(bm);
73 SkPaint paint;
74 paint.setShader(shader);
75 canvas.drawPaint(paint);
76 testCreate<SkBitmapTraits>(reporter, bm);
77 }
78
79 // Test SkColorFilter 63 // Test SkColorFilter
80 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateLightingFilter(SK_ColorB LUE, SK_ColorRED)); 64 SkAutoTUnref<SkColorFilter> cf(SkColorFilter::CreateLightingFilter(SK_ColorB LUE, SK_ColorRED));
81 testCreate<SkFlattenableTraits>(reporter, *cf); 65 testCreate<SkFlattenableTraits>(reporter, *cf);
82 66
83 // Test SkXfermode 67 // Test SkXfermode
84 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kDstOver_Mode)) ; 68 SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kDstOver_Mode)) ;
85 testCreate<SkFlattenableTraits>(reporter, *xfer); 69 testCreate<SkFlattenableTraits>(reporter, *xfer);
86 } 70 }
OLDNEW
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698