| OLD | NEW |
| 1 #include "DMGpuTask.h" | 1 #include "DMGpuTask.h" |
| 2 | 2 |
| 3 #include "DMComparisonTask.h" | 3 #include "DMComparisonTask.h" |
| 4 #include "DMUtil.h" | 4 #include "DMUtil.h" |
| 5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
| 6 #include "SkGpuDevice.h" | 6 #include "SkGpuDevice.h" |
| 7 #include "SkTLS.h" | 7 #include "SkTLS.h" |
| 8 | 8 |
| 9 namespace DM { | 9 namespace DM { |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 , fConfig(config) | 23 , fConfig(config) |
| 24 , fContextType(contextType) | 24 , fContextType(contextType) |
| 25 , fSampleCount(sampleCount) | 25 , fSampleCount(sampleCount) |
| 26 {} | 26 {} |
| 27 | 27 |
| 28 static void* new_gr_context_factory() { | 28 static void* new_gr_context_factory() { |
| 29 return SkNEW(GrContextFactory); | 29 return SkNEW(GrContextFactory); |
| 30 } | 30 } |
| 31 | 31 |
| 32 static void delete_gr_context_factory(void* factory) { | 32 static void delete_gr_context_factory(void* factory) { |
| 33 return SkDELETE((GrContextFactory*) factory); | 33 SkDELETE((GrContextFactory*) factory); |
| 34 } | 34 } |
| 35 | 35 |
| 36 static GrContextFactory* get_gr_factory() { | 36 static GrContextFactory* get_gr_factory() { |
| 37 return reinterpret_cast<GrContextFactory*>(SkTLS::Get(&new_gr_context_factor
y, | 37 return reinterpret_cast<GrContextFactory*>(SkTLS::Get(&new_gr_context_factor
y, |
| 38 &delete_gr_context_fac
tory)); | 38 &delete_gr_context_fac
tory)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void GpuTask::draw() { | 41 void GpuTask::draw() { |
| 42 GrContext* gr = get_gr_factory()->get(fContextType); // Will be owned by de
vice. | 42 GrContext* gr = get_gr_factory()->get(fContextType); // Will be owned by de
vice. |
| 43 SkGpuDevice device(gr, fConfig, fGM->width(), fGM->height(), fSampleCount); | 43 SkGpuDevice device(gr, |
| 44 fConfig, |
| 45 SkScalarCeilToInt(fGM->width()), |
| 46 SkScalarCeilToInt(fGM->height()), |
| 47 fSampleCount); |
| 44 SkCanvas canvas(&device); | 48 SkCanvas canvas(&device); |
| 45 | 49 |
| 46 canvas.concat(fGM->getInitialTransform()); | 50 canvas.concat(fGM->getInitialTransform()); |
| 47 fGM->draw(&canvas); | 51 fGM->draw(&canvas); |
| 48 canvas.flush(); | 52 canvas.flush(); |
| 49 | 53 |
| 50 SkBitmap bitmap; | 54 SkBitmap bitmap; |
| 51 bitmap.setConfig(fConfig, fGM->width(), fGM->height()); | 55 bitmap.setConfig(fConfig, SkScalarCeilToInt(fGM->width()), SkScalarCeilToInt
(fGM->height())); |
| 52 canvas.readPixels(&bitmap, 0, 0); | 56 canvas.readPixels(&bitmap, 0, 0); |
| 53 | 57 |
| 54 // We offload checksum comparison to the main CPU threadpool. | 58 // We offload checksum comparison to the main CPU threadpool. |
| 55 // This cuts run time by about 30%. | 59 // This cuts run time by about 30%. |
| 56 this->spawnChild(SkNEW_ARGS(ComparisonTask, (*this, fExpectations, bitmap)))
; | 60 this->spawnChild(SkNEW_ARGS(ComparisonTask, (*this, fExpectations, bitmap)))
; |
| 57 } | 61 } |
| 58 | 62 |
| 59 bool GpuTask::shouldSkip() const { | 63 bool GpuTask::shouldSkip() const { |
| 60 return fGM->getFlags() & skiagm::GM::kSkipGPU_Flag; | 64 return SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag); |
| 61 } | 65 } |
| 62 | 66 |
| 63 } // namespace DM | 67 } // namespace DM |
| OLD | NEW |