| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 SkPaint()); | 107 SkPaint()); |
| 108 pic.reset(recorder.endRecording()); | 108 pic.reset(recorder.endRecording()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 unsigned key[1] = { 0 }; | 111 unsigned key[1] = { 0 }; |
| 112 | 112 |
| 113 SkPaint paint; | 113 SkPaint paint; |
| 114 GrLayerCache* layerCache = context->getLayerCache(); | 114 GrLayerCache* layerCache = context->getLayerCache(); |
| 115 GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2, | 115 GrCachedLayer* layer = layerCache->findLayerOrCreate(pic->uniqueID(), 0, 2, |
| 116 SkIRect::MakeWH(kWidth,
kHeight), | 116 SkIRect::MakeWH(kWidth,
kHeight), |
| 117 SkIRect::MakeWH(kWidth,
kHeight), |
| 117 SkMatrix::I(), key, 1,
&paint); | 118 SkMatrix::I(), key, 1,
&paint); |
| 118 | 119 |
| 119 GrSurfaceDesc desc; | 120 GrSurfaceDesc desc; |
| 120 desc.fConfig = kSkia8888_GrPixelConfig; | 121 desc.fConfig = kSkia8888_GrPixelConfig; |
| 121 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 122 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 122 desc.fWidth = kWidth; | 123 desc.fWidth = kWidth; |
| 123 desc.fHeight = kHeight; | 124 desc.fHeight = kHeight; |
| 124 desc.fSampleCnt = 0; | 125 desc.fSampleCnt = 0; |
| 125 | 126 |
| 126 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); | 127 SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0
)); |
| 127 layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight)); | 128 layer->setTexture(texture, SkIRect::MakeWH(kWidth, kHeight)); |
| 128 | 129 |
| 129 SkAutoTUnref<SkBBoxHierarchy> bbh; | 130 SkAutoTUnref<SkBBoxHierarchy> bbh; |
| 130 | 131 |
| 131 SkRecord rerecord; | 132 SkRecord rerecord; |
| 132 SkRecorder canvas(&rerecord, kWidth, kHeight); | 133 SkRecorder canvas(&rerecord, kWidth, kHeight); |
| 133 GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), NULL/*callback*
/); | 134 GrRecordReplaceDraw(pic, &canvas, layerCache, SkMatrix::I(), NULL/*callback*
/); |
| 134 | 135 |
| 135 int recount = rerecord.count(); | 136 int recount = rerecord.count(); |
| 136 REPORTER_ASSERT(r, 5 == recount || 7 == recount); | 137 REPORTER_ASSERT(r, 2 == recount || 4 == recount); |
| 137 | 138 |
| 138 int index = 0; | 139 int index = 0; |
| 139 if (7 == recount) { | 140 if (4 == recount) { |
| 140 assert_type<SkRecords::Save>(r, rerecord, 0); | 141 assert_type<SkRecords::Save>(r, rerecord, 0); |
| 141 index += 1; | 142 index += 1; |
| 142 } | 143 } |
| 143 assert_type<SkRecords::Save>(r, rerecord, index + 0); | 144 assert_type<SkRecords::DrawSprite>(r, rerecord, index + 0); |
| 144 assert_type<SkRecords::SetMatrix>(r, rerecord, index + 1); | 145 assert_type<SkRecords::DrawRect>(r, rerecord, index + 1); |
| 145 assert_type<SkRecords::DrawBitmapRectToRect>(r, rerecord, index + 2); | 146 if (4 == recount) { |
| 146 assert_type<SkRecords::Restore>(r, rerecord, index + 3); | 147 assert_type<SkRecords::Restore>(r, rerecord, 3); |
| 147 assert_type<SkRecords::DrawRect>(r, rerecord, index + 4); | |
| 148 if (7 == recount) { | |
| 149 assert_type<SkRecords::Restore>(r, rerecord, 6); | |
| 150 } | 148 } |
| 151 } | 149 } |
| 152 | 150 |
| 153 DEF_GPUTEST(RecordReplaceDraw, r, factory) { | 151 DEF_GPUTEST(RecordReplaceDraw, r, factory) { |
| 154 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { | 152 for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) { |
| 155 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); | 153 GrContextFactory::GLContextType glType = static_cast<GrContextFactory::G
LContextType>(type); |
| 156 if (!GrContextFactory::IsRenderingGLContext(glType)) { | 154 if (!GrContextFactory::IsRenderingGLContext(glType)) { |
| 157 continue; | 155 continue; |
| 158 } | 156 } |
| 159 GrContext* context = factory->get(glType); | 157 GrContext* context = factory->get(glType); |
| 160 if (NULL == context) { | 158 if (NULL == context) { |
| 161 continue; | 159 continue; |
| 162 } | 160 } |
| 163 | 161 |
| 164 test_replacements(r, context, true); | 162 test_replacements(r, context, true); |
| 165 test_replacements(r, context, false); | 163 test_replacements(r, context, false); |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 | 166 |
| 169 #endif | 167 #endif |
| OLD | NEW |