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

Side by Side Diff: bench/ColorCubeBench.cpp

Issue 1798133003: Revert of Finish conversion to sk_sp<SkShader> (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « bench/AlternatingColorPatternBench.cpp ('k') | bench/GameBench.cpp » ('j') | 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 2014 Google Inc. 2 * Copyright 2014 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 #include "Benchmark.h" 7 #include "Benchmark.h"
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorCubeFilter.h" 9 #include "SkColorCubeFilter.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
(...skipping 30 matching lines...) Expand all
41 41
42 void onDraw(int loops, SkCanvas* canvas) override { 42 void onDraw(int loops, SkCanvas* canvas) override {
43 this->test(loops, canvas); 43 this->test(loops, canvas);
44 } 44 }
45 45
46 SkIPoint onGetSize() override { 46 SkIPoint onGetSize() override {
47 return SkIPoint::Make(fSize.width(), fSize.height()); 47 return SkIPoint::Make(fSize.width(), fSize.height());
48 } 48 }
49 49
50 private: 50 private:
51 static sk_sp<SkShader> MakeLinear(const SkISize& size) { 51 static SkShader* MakeLinear(const SkISize& size) {
52 const SkPoint pts[2] = { 52 const SkPoint pts[2] = {
53 { 0, 0 }, 53 { 0, 0 },
54 { SkIntToScalar(size.width()), SkIntToScalar(size.height()) } 54 { SkIntToScalar(size.width()), SkIntToScalar(size.height()) }
55 }; 55 };
56 static const SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE }; 56 static const SkColor colors[] = { SK_ColorYELLOW, SK_ColorBLUE };
57 return SkGradientShader::MakeLinear( 57 return SkGradientShader::CreateLinear(
58 pts, colors, nullptr, 2, SkShader::kRepeat_TileMode, 0, &SkMatrix::I ()); 58 pts, colors, nullptr, 2, SkShader::kRepeat_TileMode, 0, &SkMatrix::I ());
59 } 59 }
60 60
61 void make_bitmap() { 61 void make_bitmap() {
62 fBitmap.allocN32Pixels(fSize.width(), fSize.height()); 62 fBitmap.allocN32Pixels(fSize.width(), fSize.height());
63 SkCanvas canvas(fBitmap); 63 SkCanvas canvas(fBitmap);
64 canvas.clear(0x00000000); 64 canvas.clear(0x00000000);
65 SkPaint paint; 65 SkPaint paint;
66 paint.setAntiAlias(true); 66 paint.setAntiAlias(true);
67 paint.setShader(MakeLinear(fSize)); 67 SkShader* shader = MakeLinear(fSize);
68 paint.setShader(shader);
68 SkRect r = { 0, 0, SkIntToScalar(fSize.width()), SkIntToScalar(fSize.hei ght()) }; 69 SkRect r = { 0, 0, SkIntToScalar(fSize.width()), SkIntToScalar(fSize.hei ght()) };
69 canvas.drawRect(r, paint); 70 canvas.drawRect(r, paint);
71 shader->unref();
70 } 72 }
71 73
72 void makeCubeData() { 74 void makeCubeData() {
73 fCubeDimension = 32; 75 fCubeDimension = 32;
74 fCubeData = SkData::NewUninitialized(sizeof(SkColor) * 76 fCubeData = SkData::NewUninitialized(sizeof(SkColor) *
75 fCubeDimension * fCubeDimension * fCubeDimension); 77 fCubeDimension * fCubeDimension * fCubeDimension);
76 SkColor* pixels = (SkColor*)(fCubeData->writable_data()); 78 SkColor* pixels = (SkColor*)(fCubeData->writable_data());
77 SkAutoTMalloc<uint8_t> lutMemory(fCubeDimension); 79 SkAutoTMalloc<uint8_t> lutMemory(fCubeDimension);
78 uint8_t* lut = lutMemory.get(); 80 uint8_t* lut = lutMemory.get();
79 const int maxIndex = fCubeDimension - 1; 81 const int maxIndex = fCubeDimension - 1;
(...skipping 21 matching lines...) Expand all
101 canvas->drawBitmap(fBitmap, 0, 0, &paint); 103 canvas->drawBitmap(fBitmap, 0, 0, &paint);
102 } 104 }
103 } 105 }
104 106
105 typedef Benchmark INHERITED; 107 typedef Benchmark INHERITED;
106 }; 108 };
107 109
108 /////////////////////////////////////////////////////////////////////////////// 110 ///////////////////////////////////////////////////////////////////////////////
109 111
110 DEF_BENCH( return new ColorCubeBench(); ) 112 DEF_BENCH( return new ColorCubeBench(); )
OLDNEW
« no previous file with comments | « bench/AlternatingColorPatternBench.cpp ('k') | bench/GameBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698