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

Side by Side Diff: dm/DMGpuGMTask.cpp

Issue 319043005: Support using OpenGL ES context on desktop (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add docs Created 6 years, 5 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
OLDNEW
1 #include "DMGpuGMTask.h" 1 #include "DMGpuGMTask.h"
2 2
3 #include "DMExpectationsTask.h" 3 #include "DMExpectationsTask.h"
4 #include "DMUtil.h" 4 #include "DMUtil.h"
5 #include "DMWriteTask.h" 5 #include "DMWriteTask.h"
6 #include "SkCommandLineFlags.h" 6 #include "SkCommandLineFlags.h"
7 #include "SkSurface.h" 7 #include "SkSurface.h"
8 #include "SkTLS.h" 8 #include "SkTLS.h"
9 9
10 namespace DM { 10 namespace DM {
11 11
12 GpuGMTask::GpuGMTask(const char* config, 12 GpuGMTask::GpuGMTask(const char* config,
13 Reporter* reporter, 13 Reporter* reporter,
14 TaskRunner* taskRunner, 14 TaskRunner* taskRunner,
15 skiagm::GMRegistry::Factory gmFactory, 15 skiagm::GMRegistry::Factory gmFactory,
16 const Expectations& expectations, 16 const Expectations& expectations,
17 GrContextFactory::GLContextType contextType, 17 GrContextFactory::GLContextType contextType,
18 GrGLStandard gpuAPI,
18 int sampleCount) 19 int sampleCount)
19 : GpuTask(reporter, taskRunner) 20 : GpuTask(reporter, taskRunner)
20 , fGM(gmFactory(NULL)) 21 , fGM(gmFactory(NULL))
21 , fName(UnderJoin(fGM->getName(), config)) 22 , fName(UnderJoin(fGM->getName(), config))
22 , fExpectations(expectations) 23 , fExpectations(expectations)
23 , fContextType(contextType) 24 , fContextType(contextType)
25 , fGpuAPI(gpuAPI)
24 , fSampleCount(sampleCount) 26 , fSampleCount(sampleCount)
25 {} 27 {}
26 28
27 void GpuGMTask::draw(GrContextFactory* grFactory) { 29 void GpuGMTask::draw(GrContextFactory* grFactory) {
28 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()), 30 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()),
29 SkScalarCeilToInt(fGM->height()), 31 SkScalarCeilToInt(fGM->height()),
30 kN32_SkColorType, 32 kN32_SkColorType,
31 kPremul_SkAlphaType); 33 kPremul_SkAlphaType);
32 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, info, fSampleCount)); 34 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA PI, info,
35 fSampleCount));
36 if (!surface) {
37 this->fail("Could not create context for the config and the api.");
38 return;
39 }
33 SkCanvas* canvas = surface->getCanvas(); 40 SkCanvas* canvas = surface->getCanvas();
34 41
35 canvas->concat(fGM->getInitialTransform()); 42 canvas->concat(fGM->getInitialTransform());
36 fGM->draw(canvas); 43 fGM->draw(canvas);
37 canvas->flush(); 44 canvas->flush();
38 45
39 SkBitmap bitmap; 46 SkBitmap bitmap;
40 bitmap.setInfo(info); 47 bitmap.setInfo(info);
41 canvas->readPixels(&bitmap, 0, 0); 48 canvas->readPixels(&bitmap, 0, 0);
42 49
43 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap) )); 50 this->spawnChild(SkNEW_ARGS(ExpectationsTask, (*this, fExpectations, bitmap) ));
44 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap))); 51 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
45 } 52 }
46 53
47 bool GpuGMTask::shouldSkip() const { 54 bool GpuGMTask::shouldSkip() const {
48 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag) ; 55 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag) ;
49 } 56 }
50 57
51 } // namespace DM 58 } // namespace DM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698