Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #ifndef PictureRenderer_DEFINED | 8 #ifndef PictureRenderer_DEFINED |
| 9 #define PictureRenderer_DEFINED | 9 #define PictureRenderer_DEFINED |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 namespace sk_tools { | 37 namespace sk_tools { |
| 38 | 38 |
| 39 class TiledPictureRenderer; | 39 class TiledPictureRenderer; |
| 40 | 40 |
| 41 class PictureRenderer : public SkRefCnt { | 41 class PictureRenderer : public SkRefCnt { |
| 42 | 42 |
| 43 public: | 43 public: |
| 44 enum SkDeviceTypes { | 44 enum SkDeviceTypes { |
| 45 #if SK_ANGLE | 45 #if SK_ANGLE |
| 46 kAngle_DeviceType, | 46 kAngle_DeviceType, |
| 47 kAngle_GL_DeviceType, | |
|
bsalomon
2015/09/11 18:54:47
The PictureRenderer stuff isn't really used anymor
| |
| 47 #endif | 48 #endif |
| 48 #if SK_COMMAND_BUFFER | 49 #if SK_COMMAND_BUFFER |
| 49 kCommandBuffer_DeviceType, | 50 kCommandBuffer_DeviceType, |
| 50 #endif | 51 #endif |
| 51 #if SK_MESA | 52 #if SK_MESA |
| 52 kMesa_DeviceType, | 53 kMesa_DeviceType, |
| 53 #endif | 54 #endif |
| 54 kBitmap_DeviceType, | 55 kBitmap_DeviceType, |
| 55 #if SK_SUPPORT_GPU | 56 #if SK_SUPPORT_GPU |
| 56 kGPU_DeviceType, | 57 kGPU_DeviceType, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 171 |
| 171 /** | 172 /** |
| 172 * Set the backend type. Returns true on success and false on failure. | 173 * Set the backend type. Returns true on success and false on failure. |
| 173 */ | 174 */ |
| 174 #if SK_SUPPORT_GPU | 175 #if SK_SUPPORT_GPU |
| 175 bool setDeviceType(SkDeviceTypes deviceType, GrGLStandard gpuAPI = kNone_GrG LStandard) { | 176 bool setDeviceType(SkDeviceTypes deviceType, GrGLStandard gpuAPI = kNone_GrG LStandard) { |
| 176 #else | 177 #else |
| 177 bool setDeviceType(SkDeviceTypes deviceType) { | 178 bool setDeviceType(SkDeviceTypes deviceType) { |
| 178 #endif | 179 #endif |
| 179 fDeviceType = deviceType; | 180 fDeviceType = deviceType; |
| 181 if (deviceType == kBitmap_DeviceType) { | |
| 182 return true; | |
| 183 } | |
| 184 | |
| 180 #if SK_SUPPORT_GPU | 185 #if SK_SUPPORT_GPU |
| 181 // In case this function is called more than once | 186 // In case this function is called more than once |
| 182 SkSafeUnref(fGrContext); | 187 SkSafeUnref(fGrContext); |
| 183 fGrContext = nullptr; | 188 fGrContext = nullptr; |
| 184 // Set to Native so it will have an initial value. | 189 // Set to Native so it will have an initial value. |
| 185 GrContextFactory::GLContextType glContextType = GrContextFactory::kNativ e_GLContextType; | 190 GrContextFactory::GLContextType glContextType = getGPUContextType(fDevic eType); |
| 186 #endif | 191 if (GrContextFactory::kNull_GLContextType == glContextType) { |
| 187 switch(deviceType) { | 192 return false; |
| 188 case kBitmap_DeviceType: | |
| 189 return true; | |
| 190 #if SK_SUPPORT_GPU | |
| 191 case kGPU_DeviceType: | |
| 192 // Already set to GrContextFactory::kNative_GLContextType, above . | |
| 193 break; | |
| 194 case kNVPR_DeviceType: | |
| 195 glContextType = GrContextFactory::kNVPR_GLContextType; | |
| 196 break; | |
| 197 #if SK_ANGLE | |
| 198 case kAngle_DeviceType: | |
| 199 glContextType = GrContextFactory::kANGLE_GLContextType; | |
| 200 break; | |
| 201 #endif | |
| 202 #if SK_COMMAND_BUFFER | |
| 203 case kCommandBuffer_DeviceType: | |
| 204 glContextType = GrContextFactory::kCommandBuffer_GLContextType; | |
| 205 break; | |
| 206 #endif | |
| 207 #if SK_MESA | |
| 208 case kMesa_DeviceType: | |
| 209 glContextType = GrContextFactory::kMESA_GLContextType; | |
| 210 break; | |
| 211 #endif | |
| 212 #endif | |
| 213 default: | |
| 214 // Invalid device type. | |
| 215 return false; | |
| 216 } | 193 } |
| 217 #if SK_SUPPORT_GPU | 194 |
| 218 fGrContext = fGrContextFactory.get(glContextType, gpuAPI); | 195 fGrContext = fGrContextFactory.get(glContextType, gpuAPI); |
| 219 if (nullptr == fGrContext) { | 196 if (nullptr == fGrContext) { |
| 220 return false; | 197 return false; |
| 221 } else { | 198 } else { |
| 222 fGrContext->ref(); | 199 fGrContext->ref(); |
| 223 return true; | 200 return true; |
| 224 } | 201 } |
| 225 #endif | 202 #endif |
| 203 return false; | |
| 226 } | 204 } |
| 227 | 205 |
| 228 #if SK_SUPPORT_GPU | 206 #if SK_SUPPORT_GPU |
| 229 void setSampleCount(int sampleCount) { | 207 void setSampleCount(int sampleCount) { |
| 230 fSampleCount = sampleCount; | 208 fSampleCount = sampleCount; |
| 231 } | 209 } |
| 232 | 210 |
| 233 void setUseDFText(bool useDFText) { | 211 void setUseDFText(bool useDFText) { |
| 234 fUseDFText = useDFText; | 212 fUseDFText = useDFText; |
| 235 } | 213 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 config.append("_gpu"); | 266 config.append("_gpu"); |
| 289 } | 267 } |
| 290 break; | 268 break; |
| 291 case kNVPR_DeviceType: | 269 case kNVPR_DeviceType: |
| 292 config.appendf("_nvprmsaa%d", fSampleCount); | 270 config.appendf("_nvprmsaa%d", fSampleCount); |
| 293 break; | 271 break; |
| 294 #if SK_ANGLE | 272 #if SK_ANGLE |
| 295 case kAngle_DeviceType: | 273 case kAngle_DeviceType: |
| 296 config.append("_angle"); | 274 config.append("_angle"); |
| 297 break; | 275 break; |
| 276 case kAngle_GL_DeviceType: | |
| 277 config.append("_angle-gl"); | |
| 278 break; | |
| 298 #endif | 279 #endif |
| 299 #if SK_COMMAND_BUFFER | 280 #if SK_COMMAND_BUFFER |
| 300 case kCommandBuffer_DeviceType: | 281 case kCommandBuffer_DeviceType: |
| 301 config.append("_commandbuffer"); | 282 config.append("_commandbuffer"); |
| 302 break; | 283 break; |
| 303 #endif | 284 #endif |
| 304 #if SK_MESA | 285 #if SK_MESA |
| 305 case kMesa_DeviceType: | 286 case kMesa_DeviceType: |
| 306 config.append("_mesa"); | 287 config.append("_mesa"); |
| 307 break; | 288 break; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 break; | 323 break; |
| 343 case kNVPR_DeviceType: | 324 case kNVPR_DeviceType: |
| 344 tmp = "nvprmsaa"; | 325 tmp = "nvprmsaa"; |
| 345 tmp.appendS32(fSampleCount); | 326 tmp.appendS32(fSampleCount); |
| 346 result["config"] = tmp.c_str(); | 327 result["config"] = tmp.c_str(); |
| 347 break; | 328 break; |
| 348 #if SK_ANGLE | 329 #if SK_ANGLE |
| 349 case kAngle_DeviceType: | 330 case kAngle_DeviceType: |
| 350 result["config"] = "angle"; | 331 result["config"] = "angle"; |
| 351 break; | 332 break; |
| 333 case kAngle_GL_DeviceType: | |
| 334 result["config"] = "angle-gl"; | |
| 335 break; | |
| 352 #endif | 336 #endif |
| 353 #if SK_COMMAND_BUFFER | 337 #if SK_COMMAND_BUFFER |
| 354 case kCommandBuffer_DeviceType: | 338 case kCommandBuffer_DeviceType: |
| 355 result["config"] = "commandbuffer"; | 339 result["config"] = "commandbuffer"; |
| 356 break; | 340 break; |
| 357 #endif | 341 #endif |
| 358 #if SK_MESA | 342 #if SK_MESA |
| 359 case kMesa_DeviceType: | 343 case kMesa_DeviceType: |
| 360 result["config"] = "mesa"; | 344 result["config"] = "mesa"; |
| 361 break; | 345 break; |
| 362 #endif | 346 #endif |
| 363 default: | 347 default: |
| 364 // Assume that no extra info means bitmap. | 348 // Assume that no extra info means bitmap. |
| 365 break; | 349 break; |
| 366 } | 350 } |
| 367 #endif | 351 #endif |
| 368 return result; | 352 return result; |
| 369 } | 353 } |
| 370 | 354 |
| 371 #if SK_SUPPORT_GPU | 355 #if SK_SUPPORT_GPU |
| 372 bool isUsingGpuDevice() { | 356 bool isUsingGpuDevice() { |
| 373 switch (fDeviceType) { | 357 switch (fDeviceType) { |
| 374 case kGPU_DeviceType: | 358 case kGPU_DeviceType: |
| 375 case kNVPR_DeviceType: | 359 case kNVPR_DeviceType: |
| 376 // fall through | 360 // fall through |
| 377 #if SK_ANGLE | 361 #if SK_ANGLE |
| 378 case kAngle_DeviceType: | 362 case kAngle_DeviceType: |
| 363 case kAngle_GL_DeviceType: | |
| 379 // fall through | 364 // fall through |
| 380 #endif | 365 #endif |
| 381 #if SK_COMMAND_BUFFER | 366 #if SK_COMMAND_BUFFER |
| 382 case kCommandBuffer_DeviceType: | 367 case kCommandBuffer_DeviceType: |
| 383 // fall through | 368 // fall through |
| 384 #endif | 369 #endif |
| 385 #if SK_MESA | 370 #if SK_MESA |
| 386 case kMesa_DeviceType: | 371 case kMesa_DeviceType: |
| 387 #endif | 372 #endif |
| 388 return true; | 373 return true; |
| 389 default: | 374 default: |
| 390 return false; | 375 return false; |
| 391 } | 376 } |
| 392 } | 377 } |
| 393 | 378 |
| 394 SkGLContext* getGLContext() { | 379 SkGLContext* getGLContext() { |
| 395 GrContextFactory::GLContextType glContextType | 380 GrContextFactory::GLContextType glContextType = getGPUContextType(fDevic eType); |
| 396 = GrContextFactory::kNull_GLContextType; | 381 if (GrContextFactory::kNull_GLContextType == glContextType) { |
| 397 switch(fDeviceType) { | 382 return nullptr; |
| 398 case kGPU_DeviceType: | |
| 399 glContextType = GrContextFactory::kNative_GLContextType; | |
| 400 break; | |
| 401 case kNVPR_DeviceType: | |
| 402 glContextType = GrContextFactory::kNVPR_GLContextType; | |
| 403 break; | |
| 404 #if SK_ANGLE | |
| 405 case kAngle_DeviceType: | |
| 406 glContextType = GrContextFactory::kANGLE_GLContextType; | |
| 407 break; | |
| 408 #endif | |
| 409 #if SK_COMMAND_BUFFER | |
| 410 case kCommandBuffer_DeviceType: | |
| 411 glContextType = GrContextFactory::kCommandBuffer_GLContextType; | |
| 412 break; | |
| 413 #endif | |
| 414 #if SK_MESA | |
| 415 case kMesa_DeviceType: | |
| 416 glContextType = GrContextFactory::kMESA_GLContextType; | |
| 417 break; | |
| 418 #endif | |
| 419 default: | |
| 420 return nullptr; | |
| 421 } | 383 } |
| 422 return fGrContextFactory.getGLContext(glContextType); | 384 return fGrContextFactory.getGLContext(glContextType); |
| 423 } | 385 } |
| 424 | 386 |
| 425 GrContext* getGrContext() { | 387 GrContext* getGrContext() { |
| 426 return fGrContext; | 388 return fGrContext; |
| 427 } | 389 } |
| 428 | 390 |
| 429 const GrContextOptions& getGrContextOptions() { | 391 const GrContextOptions& getGrContextOptions() { |
| 430 return fGrContextFactory.getGlobalOptions(); | 392 return fGrContextFactory.getGlobalOptions(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 SkBBHFactory* getFactory(); | 467 SkBBHFactory* getFactory(); |
| 506 uint32_t recordFlags() const { return 0; } | 468 uint32_t recordFlags() const { return 0; } |
| 507 SkCanvas* setupCanvas(); | 469 SkCanvas* setupCanvas(); |
| 508 virtual SkCanvas* setupCanvas(int width, int height); | 470 virtual SkCanvas* setupCanvas(int width, int height); |
| 509 | 471 |
| 510 /** | 472 /** |
| 511 * Copy src to dest; if src==nullptr, set dest to empty string. | 473 * Copy src to dest; if src==nullptr, set dest to empty string. |
| 512 */ | 474 */ |
| 513 static void CopyString(SkString* dest, const SkString* src); | 475 static void CopyString(SkString* dest, const SkString* src); |
| 514 | 476 |
| 477 #if SK_SUPPORT_GPU | |
| 478 /** | |
| 479 * Get the context type for a given device type. Returns kNull_GLContextTyp e for non gpu | |
| 480 * device types. | |
| 481 */ | |
| 482 GrContextFactory::GLContextType getGPUContextType(SkDeviceTypes deviceType) const { | |
| 483 GrContextFactory::GLContextType glContextType = GrContextFactory::kNull_ GLContextType; | |
| 484 switch(deviceType) { | |
| 485 case kGPU_DeviceType: | |
| 486 glContextType = GrContextFactory::kNative_GLContextType; | |
| 487 break; | |
| 488 case kNVPR_DeviceType: | |
| 489 glContextType = GrContextFactory::kNVPR_GLContextType; | |
| 490 break; | |
| 491 #if SK_ANGLE | |
| 492 case kAngle_DeviceType: | |
| 493 glContextType = GrContextFactory::kANGLE_GLContextType; | |
| 494 break; | |
| 495 case kAngle_GL_DeviceType: | |
| 496 glContextType = GrContextFactory::kANGLE_GL_GLContextType; | |
| 497 break; | |
| 498 #endif // SK_ANGLE | |
| 499 #if SK_COMMAND_BUFFER | |
| 500 case kCommandBuffer_DeviceType: | |
| 501 glContextType = GrContextFactory::kCommandBuffer_GLContextType; | |
| 502 break; | |
| 503 #endif // SK_COMMAND_BUFFER | |
| 504 #if SK_MESA | |
| 505 case kMesa_DeviceType: | |
| 506 glContextType = GrContextFactory::kMESA_GLContextType; | |
| 507 break; | |
| 508 #endif // SK_MESA | |
| 509 } | |
| 510 return glContextType; | |
| 511 } | |
| 512 #endif // SK_SUPPORT_GPU | |
| 513 | |
| 515 private: | 514 private: |
| 516 SkISize fViewport; | 515 SkISize fViewport; |
| 517 SkScalar fScaleFactor; | 516 SkScalar fScaleFactor; |
| 518 #if SK_SUPPORT_GPU | 517 #if SK_SUPPORT_GPU |
| 519 GrContextFactory fGrContextFactory; | 518 GrContextFactory fGrContextFactory; |
| 520 GrContext* fGrContext; | 519 GrContext* fGrContext; |
| 521 int fSampleCount; | 520 int fSampleCount; |
| 522 bool fUseDFText; | 521 bool fUseDFText; |
| 523 #endif | 522 #endif |
| 524 | 523 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 | 745 |
| 747 #if SK_SUPPORT_GPU | 746 #if SK_SUPPORT_GPU |
| 748 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op ts); | 747 extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& op ts); |
| 749 #else | 748 #else |
| 750 extern PictureRenderer* CreateGatherPixelRefsRenderer(); | 749 extern PictureRenderer* CreateGatherPixelRefsRenderer(); |
| 751 #endif | 750 #endif |
| 752 | 751 |
| 753 } | 752 } |
| 754 | 753 |
| 755 #endif // PictureRenderer_DEFINED | 754 #endif // PictureRenderer_DEFINED |
| OLD | NEW |