OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef GrGpu_DEFINED | 8 #ifndef GrGpu_DEFINED |
11 #define GrGpu_DEFINED | 9 #define GrGpu_DEFINED |
12 | 10 |
13 #include "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
14 #include "GrRect.h" | |
15 #include "GrRefCnt.h" | 12 #include "GrRefCnt.h" |
16 #include "GrClipMaskManager.h" | 13 #include "GrClipMaskManager.h" |
17 | |
18 #include "SkPath.h" | 14 #include "SkPath.h" |
19 | 15 |
20 class GrContext; | 16 class GrContext; |
21 class GrIndexBufferAllocPool; | 17 class GrIndexBufferAllocPool; |
22 class GrPath; | 18 class GrPath; |
23 class GrPathRenderer; | 19 class GrPathRenderer; |
24 class GrPathRendererChain; | 20 class GrPathRendererChain; |
25 class GrResource; | 21 class GrResource; |
26 class GrStencilBuffer; | 22 class GrStencilBuffer; |
27 class GrVertexBufferAllocPool; | 23 class GrVertexBufferAllocPool; |
28 | 24 |
29 class GrGpu : public GrDrawTarget { | 25 class GrGpu : public GrDrawTarget { |
30 | |
31 public: | 26 public: |
32 | 27 |
33 /** | 28 /** |
34 * Additional blend coefficients for dual source blending, not exposed | 29 * Additional blend coefficients for dual source blending, not exposed |
35 * through GrPaint/GrContext. | 30 * through GrPaint/GrContext. |
36 */ | 31 */ |
37 enum ExtendedBlendCoeffs { | 32 enum ExtendedBlendCoeffs { |
38 // source 2 refers to second output color when | 33 // source 2 refers to second output color when |
39 // using dual source blending. | 34 // using dual source blending. |
40 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, | 35 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void insertResource(GrResource* resource); | 257 void insertResource(GrResource* resource); |
263 | 258 |
264 /** | 259 /** |
265 * Remove resource from list of resources. Should only be called by | 260 * Remove resource from list of resources. Should only be called by |
266 * GrResource. | 261 * GrResource. |
267 * @param resource the resource to remove. | 262 * @param resource the resource to remove. |
268 */ | 263 */ |
269 void removeResource(GrResource* resource); | 264 void removeResource(GrResource* resource); |
270 | 265 |
271 // GrDrawTarget overrides | 266 // GrDrawTarget overrides |
272 virtual void clear(const GrIRect* rect, | 267 virtual void clear(const SkIRect* rect, |
273 GrColor color, | 268 GrColor color, |
274 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 269 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
275 | 270 |
276 virtual void purgeResources() SK_OVERRIDE { | 271 virtual void purgeResources() SK_OVERRIDE { |
277 // The clip mask manager can rebuild all its clip masks so just | 272 // The clip mask manager can rebuild all its clip masks so just |
278 // get rid of them all. | 273 // get rid of them all. |
279 fClipMaskManager.releaseResources(); | 274 fClipMaskManager.releaseResources(); |
280 } | 275 } |
281 | 276 |
282 // After the client interacts directly with the 3D context state the GrGpu | 277 // After the client interacts directly with the 3D context state the GrGpu |
(...skipping 20 matching lines...) Expand all Loading... |
303 GrAssert(kGrPixelConfigCnt > config); | 298 GrAssert(kGrPixelConfigCnt > config); |
304 return fConfigRenderSupport[config]; | 299 return fConfigRenderSupport[config]; |
305 } | 300 } |
306 | 301 |
307 /** | 302 /** |
308 * These methods are called by the clip manager's setupClipping function | 303 * These methods are called by the clip manager's setupClipping function |
309 * which (called as part of GrGpu's implementation of onDraw and | 304 * which (called as part of GrGpu's implementation of onDraw and |
310 * onStencilPath member functions.) The GrGpu subclass should flush the | 305 * onStencilPath member functions.) The GrGpu subclass should flush the |
311 * stencil state to the 3D API in its implementation of flushGraphicsState. | 306 * stencil state to the 3D API in its implementation of flushGraphicsState. |
312 */ | 307 */ |
313 void enableScissor(const GrIRect& rect) { | 308 void enableScissor(const SkIRect& rect) { |
314 fScissorState.fEnabled = true; | 309 fScissorState.fEnabled = true; |
315 fScissorState.fRect = rect; | 310 fScissorState.fRect = rect; |
316 } | 311 } |
317 void disableScissor() { fScissorState.fEnabled = false; } | 312 void disableScissor() { fScissorState.fEnabled = false; } |
318 | 313 |
319 /** | 314 /** |
320 * Like the scissor methods above this is called by setupClipping and | 315 * Like the scissor methods above this is called by setupClipping and |
321 * should be flushed by the GrGpu subclass in flushGraphicsState. These | 316 * should be flushed by the GrGpu subclass in flushGraphicsState. These |
322 * stencil settings should be used in place of those on the GrDrawState. | 317 * stencil settings should be used in place of those on the GrDrawState. |
323 * They have been adjusted to account for any interactions between the | 318 * They have been adjusted to account for any interactions between the |
324 * GrDrawState's stencil settings and stencil clipping. | 319 * GrDrawState's stencil settings and stencil clipping. |
325 */ | 320 */ |
326 void setStencilSettings(const GrStencilSettings& settings) { | 321 void setStencilSettings(const GrStencilSettings& settings) { |
327 fStencilSettings = settings; | 322 fStencilSettings = settings; |
328 } | 323 } |
329 void disableStencil() { fStencilSettings.setDisabled(); } | 324 void disableStencil() { fStencilSettings.setDisabled(); } |
330 | 325 |
331 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is | 326 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is |
332 // free to clear the remaining bits to zero if masked clears are more | 327 // free to clear the remaining bits to zero if masked clears are more |
333 // expensive than clearing all bits. | 328 // expensive than clearing all bits. |
334 virtual void clearStencilClip(const GrIRect& rect, bool insideClip) = 0; | 329 virtual void clearStencilClip(const SkIRect& rect, bool insideClip) = 0; |
335 | 330 |
336 enum PrivateDrawStateStateBits { | 331 enum PrivateDrawStateStateBits { |
337 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), | 332 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), |
338 | 333 |
339 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify | 334 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify |
340 // stencil bits used for | 335 // stencil bits used for |
341 // clipping. | 336 // clipping. |
342 }; | 337 }; |
343 | 338 |
344 protected: | 339 protected: |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 const GrIndexBuffer* fPoolIndexBuffer; | 386 const GrIndexBuffer* fPoolIndexBuffer; |
392 int fPoolStartIndex; | 387 int fPoolStartIndex; |
393 }; | 388 }; |
394 const GeometryPoolState& getGeomPoolState() { | 389 const GeometryPoolState& getGeomPoolState() { |
395 return fGeomPoolStateStack.back(); | 390 return fGeomPoolStateStack.back(); |
396 } | 391 } |
397 | 392 |
398 // The state of the scissor is controlled by the clip manager | 393 // The state of the scissor is controlled by the clip manager |
399 struct ScissorState { | 394 struct ScissorState { |
400 bool fEnabled; | 395 bool fEnabled; |
401 GrIRect fRect; | 396 SkIRect fRect; |
402 } fScissorState; | 397 } fScissorState; |
403 | 398 |
404 // The final stencil settings to use as determined by the clip manager. | 399 // The final stencil settings to use as determined by the clip manager. |
405 GrStencilSettings fStencilSettings; | 400 GrStencilSettings fStencilSettings; |
406 | 401 |
407 // Derived classes need access to this so they can fill it out in their | 402 // Derived classes need access to this so they can fill it out in their |
408 // constructors | 403 // constructors |
409 bool fConfigRenderSupport[kGrPixelConfigCnt]; | 404 bool fConfigRenderSupport[kGrPixelConfigCnt]; |
410 | 405 |
411 // Helpers for setting up geometry state | 406 // Helpers for setting up geometry state |
(...skipping 23 matching lines...) Expand all Loading... |
435 const void* srcData, | 430 const void* srcData, |
436 size_t rowBytes) = 0; | 431 size_t rowBytes) = 0; |
437 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 432 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
438 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 433 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
439 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; | 434 virtual GrVertexBuffer* onCreateVertexBuffer(uint32_t size, bool dynamic) =
0; |
440 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; | 435 virtual GrIndexBuffer* onCreateIndexBuffer(uint32_t size, bool dynamic) = 0; |
441 virtual GrPath* onCreatePath(const SkPath& path) = 0; | 436 virtual GrPath* onCreatePath(const SkPath& path) = 0; |
442 | 437 |
443 // overridden by backend-specific derived class to perform the clear and | 438 // overridden by backend-specific derived class to perform the clear and |
444 // clearRect. NULL rect means clear whole target. | 439 // clearRect. NULL rect means clear whole target. |
445 virtual void onClear(const GrIRect* rect, GrColor color) = 0; | 440 virtual void onClear(const SkIRect* rect, GrColor color) = 0; |
446 | 441 |
447 // overridden by backend-specific derived class to perform the draw call. | 442 // overridden by backend-specific derived class to perform the draw call. |
448 virtual void onGpuDraw(const DrawInfo&) = 0; | 443 virtual void onGpuDraw(const DrawInfo&) = 0; |
449 // when GrDrawTarget::stencilPath is called the draw state's current stencil | 444 // when GrDrawTarget::stencilPath is called the draw state's current stencil |
450 // settings are ignored. Instead the GrGpu decides the stencil rules | 445 // settings are ignored. Instead the GrGpu decides the stencil rules |
451 // necessary to stencil the path. These are still subject to filtering by | 446 // necessary to stencil the path. These are still subject to filtering by |
452 // the clip mask manager. | 447 // the clip mask manager. |
453 virtual void setStencilPathSettings(const GrPath&, | 448 virtual void setStencilPathSettings(const GrPath&, |
454 SkPath::FillType, | 449 SkPath::FillType, |
455 GrStencilSettings* settings) = 0; | 450 GrStencilSettings* settings) = 0; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // these are mutable so they can be created on-demand | 530 // these are mutable so they can be created on-demand |
536 mutable GrIndexBuffer* fQuadInd
exBuffer; | 531 mutable GrIndexBuffer* fQuadInd
exBuffer; |
537 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 532 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
538 // functionality to GrResourceCache. | 533 // functionality to GrResourceCache. |
539 ResourceList fResourc
eList; | 534 ResourceList fResourc
eList; |
540 | 535 |
541 typedef GrDrawTarget INHERITED; | 536 typedef GrDrawTarget INHERITED; |
542 }; | 537 }; |
543 | 538 |
544 #endif | 539 #endif |
OLD | NEW |