OLD | NEW |
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 | 7 |
8 #if SK_SUPPORT_GPU | 8 #if SK_SUPPORT_GPU |
9 | 9 |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // Test out the layer replacement functionality with and w/o a BBH | 87 // Test out the layer replacement functionality with and w/o a BBH |
88 void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) { | 88 void test_replacements(skiatest::Reporter* r, GrContext* context, bool useBBH) { |
89 SkAutoTUnref<const SkPicture> pic; | 89 SkAutoTUnref<const SkPicture> pic; |
90 | 90 |
91 { | 91 { |
92 SkRTreeFactory bbhFactory; | 92 SkRTreeFactory bbhFactory; |
93 SkPictureRecorder recorder; | 93 SkPictureRecorder recorder; |
94 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT
oScalar(kHeight), | 94 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kWidth), SkIntT
oScalar(kHeight), |
95 useBBH ? &bbhFactory : NULL); | 95 useBBH ? &bbhFactory : NULL); |
96 | 96 |
97 SkAutoTDelete<SkPaint> paint(SkNEW(SkPaint)); | 97 SkPaint paint; |
98 canvas->saveLayer(NULL, paint); | 98 canvas->saveLayer(NULL, &paint); |
99 canvas->clear(SK_ColorRED); | 99 canvas->clear(SK_ColorRED); |
100 canvas->restore(); | 100 canvas->restore(); |
101 canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar
(kHeight / 2)), | 101 canvas->drawRect(SkRect::MakeWH(SkIntToScalar(kWidth / 2), SkIntToScalar
(kHeight / 2)), |
102 SkPaint()); | 102 SkPaint()); |
103 pic.reset(recorder.endRecording()); | 103 pic.reset(recorder.endRecording()); |
104 } | 104 } |
105 | 105 |
106 unsigned key[1] = { 0 }; | 106 unsigned key[1] = { 0 }; |
107 | 107 |
| 108 SkPaint paint; |
108 GrLayerCache* layerCache = context->getLayerCache(); | 109 GrLayerCache* layerCache = context->getLayerCache(); |
109 GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2, | 110 GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2, |
110 SkIRect::MakeWH(kWidth,
kHeight), | 111 SkIRect::MakeWH(kWidth,
kHeight), |
111 SkMatrix::I(), key, 1,
SkNEW(SkPaint)); | 112 SkMatrix::I(), key, 1,
&paint); |
112 | 113 |
113 GrSurfaceDesc desc; | 114 GrSurfaceDesc desc; |
114 desc.fConfig = kSkia8888_GrPixelConfig; | 115 desc.fConfig = kSkia8888_GrPixelConfig; |
115 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 116 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
116 desc.fWidth = kWidth; | 117 desc.fWidth = kWidth; |
117 desc.fHeight = kHeight; | 118 desc.fHeight = kHeight; |
118 desc.fSampleCnt = 0; | 119 desc.fSampleCnt = 0; |
119 | 120 |
120 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); | 121 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); |
121 layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight)); | 122 layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight)); |
(...skipping 24 matching lines...) Expand all Loading... |
146 if (NULL == context) { | 147 if (NULL == context) { |
147 continue; | 148 continue; |
148 } | 149 } |
149 | 150 |
150 test_replacements(r, context, true); | 151 test_replacements(r, context, true); |
151 test_replacements(r, context, false); | 152 test_replacements(r, context, false); |
152 } | 153 } |
153 } | 154 } |
154 | 155 |
155 #endif | 156 #endif |
OLD | NEW |