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

Side by Side Diff: samplecode/SampleTextureDomain.cpp

Issue 23701006: Push sigma-based blur interface into our GMs/benches/tests/samplecode (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: cleaned up Created 7 years, 3 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 | « samplecode/SampleTextOnPath.cpp ('k') | samplecode/SampleTiling.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h"
9 #include "SkCanvas.h" 11 #include "SkCanvas.h"
10 #include "SkDevice.h" 12 #include "SkDevice.h"
11 #include "SkBlurMaskFilter.h"
12 13
13 namespace { 14 namespace {
14 SkBitmap make_bitmap() { 15 SkBitmap make_bitmap() {
15 SkBitmap bm; 16 SkBitmap bm;
16 bm.setConfig(SkBitmap::kARGB_8888_Config , 5, 5); 17 bm.setConfig(SkBitmap::kARGB_8888_Config , 5, 5);
17 bm.allocPixels(); 18 bm.allocPixels();
18 19
19 for (int y = 0; y < bm.height(); y++) { 20 for (int y = 0; y < bm.height(); y++) {
20 uint32_t* p = bm.getAddr32(0, y); 21 uint32_t* p = bm.getAddr32(0, y);
21 for (int x = 0; x < bm.width(); x++) { 22 for (int x = 0; x < bm.width(); x++) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 srcRect.setXYWH(1, 1, 3, 3); 75 srcRect.setXYWH(1, 1, 3, 3);
75 dstRect.setXYWH(405.0f, 5.0f, 305.0f, 305.0f); 76 dstRect.setXYWH(405.0f, 5.0f, 305.0f, 305.0f);
76 canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint); 77 canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint);
77 78
78 // Test that bitmap blurring using a subrect 79 // Test that bitmap blurring using a subrect
79 // renders correctly 80 // renders correctly
80 srcRect.setXYWH(1, 1, 3, 3); 81 srcRect.setXYWH(1, 1, 3, 3);
81 dstRect.setXYWH(5.0f, 405.0f, 305.0f, 305.0f); 82 dstRect.setXYWH(5.0f, 405.0f, 305.0f, 305.0f);
82 SkMaskFilter* mf = SkBlurMaskFilter::Create( 83 SkMaskFilter* mf = SkBlurMaskFilter::Create(
83 5,
84 SkBlurMaskFilter::kNormal_BlurStyle, 84 SkBlurMaskFilter::kNormal_BlurStyle,
85 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
85 SkBlurMaskFilter::kHighQuality_BlurFlag | 86 SkBlurMaskFilter::kHighQuality_BlurFlag |
86 SkBlurMaskFilter::kIgnoreTransform_BlurFlag); 87 SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
87 paint.setMaskFilter(mf)->unref(); 88 paint.setMaskFilter(mf)->unref();
88 canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint); 89 canvas->drawBitmapRect(deviceBitmap, &srcRect, dstRect, &paint);
89 90
90 // Blur and a rotation + NULL src rect 91 // Blur and a rotation + NULL src rect
91 // This should not trigger the texture domain code 92 // This should not trigger the texture domain code
92 // but it will test a code path in SkGpuDevice::drawBitmap 93 // but it will test a code path in SkGpuDevice::drawBitmap
93 // that handles blurs with rects transformed to non- 94 // that handles blurs with rects transformed to non-
94 // orthogonal rects. It also tests the NULL src rect handling 95 // orthogonal rects. It also tests the NULL src rect handling
95 mf = SkBlurMaskFilter::Create( 96 mf = SkBlurMaskFilter::Create(
96 5,
97 SkBlurMaskFilter::kNormal_BlurStyle, 97 SkBlurMaskFilter::kNormal_BlurStyle,
98 SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
98 SkBlurMaskFilter::kHighQuality_BlurFlag); 99 SkBlurMaskFilter::kHighQuality_BlurFlag);
99 paint.setMaskFilter(mf)->unref(); 100 paint.setMaskFilter(mf)->unref();
100 101
101 dstRect.setXYWH(-150.0f, -150.0f, 300.0f, 300.0f); 102 dstRect.setXYWH(-150.0f, -150.0f, 300.0f, 300.0f);
102 canvas->translate(550, 550); 103 canvas->translate(550, 550);
103 canvas->rotate(45); 104 canvas->rotate(45);
104 canvas->drawBitmapRect(fBM, NULL, dstRect, &paint); 105 canvas->drawBitmapRect(fBM, NULL, dstRect, &paint);
105 } 106 }
106 private: 107 private:
107 typedef SkView INHERITED; 108 typedef SkView INHERITED;
108 }; 109 };
109 110
110 ////////////////////////////////////////////////////////////////////////////// 111 //////////////////////////////////////////////////////////////////////////////
111 112
112 static SkView* MyFactory() { return new TextureDomainView; } 113 static SkView* MyFactory() { return new TextureDomainView; }
113 static SkViewRegister reg(MyFactory); 114 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleTextOnPath.cpp ('k') | samplecode/SampleTiling.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698