Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "OpenGLRenderer" |
| 18 | |
| 19 | #include <utils/StopWatch.h> |
| 20 | |
| 21 | #include "OpenGLDebugRenderer.h" |
| 22 | |
| 23 | namespace android { |
| 24 | namespace uirenderer { |
| 25 | |
Romain Guy | 6b7bd24 | 2010-10-06 19:49:23 -0700 | [diff] [blame] | 26 | void OpenGLDebugRenderer::prepare(bool opaque) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 27 | mPrimitivesCount = 0; |
| 28 | LOGD("========= Frame start ========="); |
Romain Guy | 6b7bd24 | 2010-10-06 19:49:23 -0700 | [diff] [blame] | 29 | OpenGLRenderer::prepare(opaque); |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | void OpenGLDebugRenderer::finish() { |
| 33 | LOGD("========= Frame end ========="); |
| 34 | LOGD("Primitives draw count = %d", mPrimitivesCount); |
| 35 | OpenGLRenderer::finish(); |
| 36 | } |
| 37 | |
| 38 | void OpenGLDebugRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { |
| 39 | mPrimitivesCount++; |
| 40 | StopWatch w("composeLayer"); |
| 41 | return OpenGLRenderer::composeLayer(current, previous); |
| 42 | } |
| 43 | |
| 44 | int OpenGLDebugRenderer::saveLayer(float left, float top, float right, float bottom, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 45 | SkPaint* p, int flags) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 46 | mPrimitivesCount++; |
| 47 | StopWatch w("saveLayer"); |
| 48 | return OpenGLRenderer::saveLayer(left, top, right, bottom, p, flags); |
| 49 | } |
| 50 | |
Romain Guy | 0fe478e | 2010-11-08 12:08:41 -0800 | [diff] [blame^] | 51 | void OpenGLDebugRenderer::drawDisplayList(DisplayList* displayList) { |
| 52 | mPrimitivesCount++; |
| 53 | StopWatch w("drawDisplayList"); |
| 54 | OpenGLRenderer::drawDisplayList(displayList); |
| 55 | } |
| 56 | |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 57 | void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float left, float top, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 58 | SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 59 | mPrimitivesCount++; |
| 60 | StopWatch w("drawBitmap"); |
| 61 | OpenGLRenderer::drawBitmap(bitmap, left, top, paint); |
| 62 | } |
| 63 | |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 64 | void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, SkMatrix* matrix, |
| 65 | SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 66 | mPrimitivesCount++; |
| 67 | StopWatch w("drawBitmapMatrix"); |
| 68 | OpenGLRenderer::drawBitmap(bitmap, matrix, paint); |
| 69 | } |
| 70 | |
| 71 | void OpenGLDebugRenderer::drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, |
| 72 | float srcRight, float srcBottom, float dstLeft, float dstTop, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 73 | float dstRight, float dstBottom, SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 74 | mPrimitivesCount++; |
| 75 | StopWatch w("drawBitmapRect"); |
| 76 | OpenGLRenderer::drawBitmap(bitmap, srcLeft, srcTop, srcRight, srcBottom, |
| 77 | dstLeft, dstTop, dstRight, dstBottom, paint); |
| 78 | } |
| 79 | |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 80 | void OpenGLDebugRenderer::drawPatch(SkBitmap* bitmap, const int32_t* xDivs, const int32_t* yDivs, |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 81 | const uint32_t* colors, uint32_t width, uint32_t height, int8_t numColors, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 82 | float left, float top, float right, float bottom, SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 83 | mPrimitivesCount++; |
| 84 | StopWatch w("drawPatch"); |
Romain Guy | 4bb9420 | 2010-10-12 15:59:26 -0700 | [diff] [blame] | 85 | OpenGLRenderer::drawPatch(bitmap, xDivs, yDivs, colors, width, height, numColors, |
Romain Guy | 4aa9057 | 2010-09-26 18:40:37 -0700 | [diff] [blame] | 86 | left, top, right, bottom, paint); |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void OpenGLDebugRenderer::drawColor(int color, SkXfermode::Mode mode) { |
| 90 | mPrimitivesCount++; |
| 91 | StopWatch w("drawColor"); |
| 92 | OpenGLRenderer::drawColor(color, mode); |
| 93 | } |
| 94 | |
| 95 | void OpenGLDebugRenderer::drawRect(float left, float top, float right, float bottom, |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 96 | SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 97 | mPrimitivesCount++; |
| 98 | StopWatch w("drawRect"); |
| 99 | OpenGLRenderer::drawRect(left, top, right, bottom, paint); |
| 100 | } |
| 101 | |
| 102 | void OpenGLDebugRenderer::drawPath(SkPath* path, SkPaint* paint) { |
| 103 | mPrimitivesCount++; |
| 104 | StopWatch w("drawPath"); |
| 105 | OpenGLRenderer::drawPath(path, paint); |
| 106 | } |
| 107 | |
Chet Haase | 5c13d89 | 2010-10-08 08:37:55 -0700 | [diff] [blame] | 108 | void OpenGLDebugRenderer::drawLines(float* points, int count, SkPaint* paint) { |
Romain Guy | e2d345e | 2010-09-24 18:39:22 -0700 | [diff] [blame] | 109 | mPrimitivesCount++; |
| 110 | StopWatch w("drawLines"); |
| 111 | OpenGLRenderer::drawLines(points, count, paint); |
| 112 | } |
| 113 | |
| 114 | void OpenGLDebugRenderer::drawText(const char* text, int bytesCount, int count, float x, float y, |
| 115 | SkPaint* paint) { |
| 116 | mPrimitivesCount++; |
| 117 | StopWatch w("drawText"); |
| 118 | OpenGLRenderer::drawText(text, bytesCount, count, x, y, paint); |
| 119 | } |
| 120 | |
| 121 | }; // namespace uirenderer |
| 122 | }; // namespace android |