OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef GrContext_DEFINED | 10 #ifndef GrContext_DEFINED |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 /** | 250 /** |
251 * Return the max width or height of a texture supported by the current GPU
. | 251 * Return the max width or height of a texture supported by the current GPU
. |
252 */ | 252 */ |
253 int getMaxTextureSize() const; | 253 int getMaxTextureSize() const; |
254 | 254 |
255 /////////////////////////////////////////////////////////////////////////// | 255 /////////////////////////////////////////////////////////////////////////// |
256 // Render targets | 256 // Render targets |
257 | 257 |
258 /** | 258 /** |
259 * Sets the render target. | 259 * Sets the render target. |
260 * @param target the render target to set. (should not be NULL.) | 260 * @param target the render target to set. |
261 */ | 261 */ |
262 void setRenderTarget(GrRenderTarget* target); | 262 void setRenderTarget(GrRenderTarget* target) { |
| 263 fRenderTarget.reset(SkSafeRef(target)); |
| 264 } |
263 | 265 |
264 /** | 266 /** |
265 * Gets the current render target. | 267 * Gets the current render target. |
266 * @return the currently bound render target. Should never be NULL. | 268 * @return the currently bound render target. |
267 */ | 269 */ |
268 const GrRenderTarget* getRenderTarget() const; | 270 const GrRenderTarget* getRenderTarget() const { return fRenderTarget.get();
} |
269 GrRenderTarget* getRenderTarget(); | 271 GrRenderTarget* getRenderTarget() { return fRenderTarget.get(); } |
270 | 272 |
271 GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; } | 273 GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; } |
272 | 274 |
273 /** | 275 /** |
274 * Can the provided configuration act as a color render target? | 276 * Can the provided configuration act as a color render target? |
275 */ | 277 */ |
276 bool isConfigRenderable(GrPixelConfig config) const; | 278 bool isConfigRenderable(GrPixelConfig config) const; |
277 | 279 |
278 /** | 280 /** |
279 * Return the max width or height of a render target supported by the | 281 * Return the max width or height of a render target supported by the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 */ | 316 */ |
315 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); | 317 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc& de
sc); |
316 | 318 |
317 /////////////////////////////////////////////////////////////////////////// | 319 /////////////////////////////////////////////////////////////////////////// |
318 // Matrix state | 320 // Matrix state |
319 | 321 |
320 /** | 322 /** |
321 * Gets the current transformation matrix. | 323 * Gets the current transformation matrix. |
322 * @return the current matrix. | 324 * @return the current matrix. |
323 */ | 325 */ |
324 const SkMatrix& getMatrix() const; | 326 const SkMatrix& getMatrix() const { return fViewMatrix; } |
325 | 327 |
326 /** | 328 /** |
327 * Sets the transformation matrix. | 329 * Sets the transformation matrix. |
328 * @param m the matrix to set. | 330 * @param m the matrix to set. |
329 */ | 331 */ |
330 void setMatrix(const SkMatrix& m); | 332 void setMatrix(const SkMatrix& m) { fViewMatrix = m; } |
331 | 333 |
332 /** | 334 /** |
333 * Sets the current transformation matrix to identity. | 335 * Sets the current transformation matrix to identity. |
334 */ | 336 */ |
335 void setIdentityMatrix(); | 337 void setIdentityMatrix() { fViewMatrix.reset(); } |
336 | 338 |
337 /** | 339 /** |
338 * Concats the current matrix. The passed matrix is applied before the | 340 * Concats the current matrix. The passed matrix is applied before the |
339 * current matrix. | 341 * current matrix. |
340 * @param m the matrix to concat. | 342 * @param m the matrix to concat. |
341 */ | 343 */ |
342 void concatMatrix(const SkMatrix& m) const; | 344 void concatMatrix(const SkMatrix& m) { fViewMatrix.preConcat(m); } |
343 | 345 |
344 | 346 |
345 /////////////////////////////////////////////////////////////////////////// | 347 /////////////////////////////////////////////////////////////////////////// |
346 // Clip state | 348 // Clip state |
347 /** | 349 /** |
348 * Gets the current clip. | 350 * Gets the current clip. |
349 * @return the current clip. | 351 * @return the current clip. |
350 */ | 352 */ |
351 const GrClipData* getClip() const; | 353 const GrClipData* getClip() const { return fClip; } |
352 | 354 |
353 /** | 355 /** |
354 * Sets the clip. | 356 * Sets the clip. |
355 * @param clipData the clip to set. | 357 * @param clipData the clip to set. |
356 */ | 358 */ |
357 void setClip(const GrClipData* clipData); | 359 void setClip(const GrClipData* clipData) { fClip = clipData; } |
358 | 360 |
359 /////////////////////////////////////////////////////////////////////////// | 361 /////////////////////////////////////////////////////////////////////////// |
360 // Draws | 362 // Draws |
361 | 363 |
362 /** | 364 /** |
363 * Clear the entire or rect of the render target, ignoring any clips. | 365 * Clear the entire or rect of the render target, ignoring any clips. |
364 * @param rect the rect to clear or the whole thing if rect is NULL. | 366 * @param rect the rect to clear or the whole thing if rect is NULL. |
365 * @param color the color to clear to. | 367 * @param color the color to clear to. |
366 * @param target if non-NULL, the render target to clear otherwise clear | 368 * @param target if non-NULL, the render target to clear otherwise clear |
367 * the current render target | 369 * the current render target |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 #endif | 859 #endif |
858 | 860 |
859 private: | 861 private: |
860 // Used to indicate whether a draw should be performed immediately or queued
in fDrawBuffer. | 862 // Used to indicate whether a draw should be performed immediately or queued
in fDrawBuffer. |
861 enum BufferedDraw { | 863 enum BufferedDraw { |
862 kYes_BufferedDraw, | 864 kYes_BufferedDraw, |
863 kNo_BufferedDraw, | 865 kNo_BufferedDraw, |
864 }; | 866 }; |
865 BufferedDraw fLastDrawWasBuffered; | 867 BufferedDraw fLastDrawWasBuffered; |
866 | 868 |
867 GrGpu* fGpu; | 869 GrGpu* fGpu; |
868 GrDrawState* fDrawState; | 870 SkMatrix fViewMatrix; |
| 871 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 872 const GrClipData* fClip; // TODO: make this ref counted |
| 873 GrDrawState* fDrawState; |
869 | 874 |
870 GrResourceCache* fTextureCache; | 875 GrResourceCache* fTextureCache; |
871 GrFontCache* fFontCache; | 876 GrFontCache* fFontCache; |
872 | 877 |
873 GrPathRendererChain* fPathRendererChain; | 878 GrPathRendererChain* fPathRendererChain; |
874 GrSoftwarePathRenderer* fSoftwarePathRenderer; | 879 GrSoftwarePathRenderer* fSoftwarePathRenderer; |
875 | 880 |
876 GrVertexBufferAllocPool* fDrawBufferVBAllocPool; | 881 GrVertexBufferAllocPool* fDrawBufferVBAllocPool; |
877 GrIndexBufferAllocPool* fDrawBufferIBAllocPool; | 882 GrIndexBufferAllocPool* fDrawBufferIBAllocPool; |
878 GrInOrderDrawBuffer* fDrawBuffer; | 883 GrInOrderDrawBuffer* fDrawBuffer; |
879 | 884 |
880 GrAARectRenderer* fAARectRenderer; | 885 GrAARectRenderer* fAARectRenderer; |
881 GrOvalRenderer* fOvalRenderer; | 886 GrOvalRenderer* fOvalRenderer; |
882 | 887 |
883 bool fDidTestPMConversions; | 888 bool fDidTestPMConversions; |
884 int fPMToUPMConversion; | 889 int fPMToUPMConversion; |
885 int fUPMToPMConversion; | 890 int fUPMToPMConversion; |
886 | 891 |
887 struct CleanUpData { | 892 struct CleanUpData { |
888 PFCleanUpFunc fFunc; | 893 PFCleanUpFunc fFunc; |
889 void* fInfo; | 894 void* fInfo; |
890 }; | 895 }; |
891 | 896 |
892 SkTDArray<CleanUpData> fCleanUpData; | 897 SkTDArray<CleanUpData> fCleanUpData; |
893 | 898 |
894 GrContext(); // init must be called after the constructor. | 899 GrContext(); // init must be called after the constructor. |
895 bool init(GrBackend, GrBackendContext); | 900 bool init(GrBackend, GrBackendContext); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 } | 1019 } |
1015 | 1020 |
1016 GrTexture* texture() { return fTexture; } | 1021 GrTexture* texture() { return fTexture; } |
1017 | 1022 |
1018 private: | 1023 private: |
1019 GrContext* fContext; | 1024 GrContext* fContext; |
1020 GrTexture* fTexture; | 1025 GrTexture* fTexture; |
1021 }; | 1026 }; |
1022 | 1027 |
1023 #endif | 1028 #endif |
OLD | NEW |